Completed
Pull Request — master (#489)
by Helpful
03:51
created
code/model/steps/UserConfirmationStep.php 1 patch
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -150,14 +150,14 @@  discard block
 block discarded – undo
150 150
         parent::start();
151 151
 
152 152
         // Just in case this step is being mistakenly restarted
153
-        if ($this->hasResponse()) {
153
+        if($this->hasResponse()) {
154 154
             $this->log("{$this->Title} has already been processed with a response of {$this->Approval}");
155 155
             $this->markFailed();
156 156
             return false;
157 157
         }
158 158
 
159 159
         // Begin or process this step
160
-        switch ($this->Status) {
160
+        switch($this->Status) {
161 161
             case 'Started':
162 162
                 return $this->checkStatus();
163 163
             case 'Queued':
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
     public function approve()
189 189
     {
190 190
         // Check permission
191
-        if (!$this->canApprove()) {
191
+        if(!$this->canApprove()) {
192 192
             return Security::permissionFailure(
193 193
                 null,
194 194
                 _t("UserConfirmationStep.DENYAPPROVE", "You do not have permission to approve this deployment")
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
         }
197 197
 
198 198
         // Skip subsequent approvals if already approved / rejected
199
-        if ($this->hasResponse()) {
199
+        if($this->hasResponse()) {
200 200
             return;
201 201
         }
202 202
 
@@ -217,7 +217,7 @@  discard block
 block discarded – undo
217 217
     public function reject()
218 218
     {
219 219
         // Check permission
220
-        if (!$this->canApprove()) {
220
+        if(!$this->canApprove()) {
221 221
             return Security::permissionFailure(
222 222
                 null,
223 223
                 _t("UserConfirmationStep.DENYREJECT", "You do not have permission to reject this deployment")
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
         }
226 226
 
227 227
         // Skip subsequent approvals if already approved / rejected
228
-        if ($this->hasResponse()) {
228
+        if($this->hasResponse()) {
229 229
             return;
230 230
         }
231 231
 
@@ -247,7 +247,7 @@  discard block
 block discarded – undo
247 247
     {
248 248
         // For running or queued tasks ensure that we have not exceeded
249 249
         // a reasonable time-elapsed to consider this job inactive
250
-        if ($this->isTimedOut()) {
250
+        if($this->isTimedOut()) {
251 251
             $days = round($this->MaxDuration / (24.0 * 3600.0), 1);
252 252
             $logMessage = "{$this->Title} took longer than {$this->MaxDuration} seconds ($days days) to be approved "
253 253
                 . "and has timed out";
@@ -258,7 +258,7 @@  discard block
 block discarded – undo
258 258
         }
259 259
 
260 260
         // If operating on a delayed notification schedule, determine if there are further groups who should be notified
261
-        if ($delay = $this->getConfigSetting('RecipientsDelay')) {
261
+        if($delay = $this->getConfigSetting('RecipientsDelay')) {
262 262
             // Check group that should have been notified by now
263 263
             $age = $this->getAge();
264 264
             $escallateGroup = intval($age / $delay);
@@ -266,7 +266,7 @@  discard block
 block discarded – undo
266 266
             $lastGroup = count($recipients) - 1;
267 267
             // If we can notify the next group, do so
268 268
             // We only escallate one group at a time to ensure correct order is followed
269
-            if ($this->NotifiedGroup < $lastGroup && $this->NotifiedGroup < $escallateGroup) {
269
+            if($this->NotifiedGroup < $lastGroup && $this->NotifiedGroup < $escallateGroup) {
270 270
                 $this->NotifiedGroup++;
271 271
                 $groupDescription = is_array($recipients[$this->NotifiedGroup])
272 272
                     ? implode(',', $recipients[$this->NotifiedGroup])
@@ -295,7 +295,7 @@  discard block
 block discarded – undo
295 295
         $this->log("Starting {$this->Title}...");
296 296
         // Determine if we should use delayed notification
297 297
         $recipientGroup = 'all';
298
-        if ($this->getConfigSetting('RecipientsDelay')) {
298
+        if($this->getConfigSetting('RecipientsDelay')) {
299 299
             $this->NotifiedGroup = $recipientGroup = 0;
300 300
         }
301 301
         // Send to selected group
@@ -358,9 +358,9 @@  discard block
 block discarded – undo
358 358
         $author = $this->Pipeline()->Author();
359 359
 
360 360
         // Send message to requester
361
-        if ($recipientGroup === 'all' || $recipientGroup === 0) {
361
+        if($recipientGroup === 'all' || $recipientGroup === 0) {
362 362
             list($subject, $message) = $this->generateMessageTemplate(self::ROLE_REQUESTER, $messageID);
363
-            if ($subject && $message) {
363
+            if($subject && $message) {
364 364
                 $this->log("{$this->Title} sending $messageID message to {$author->Email}");
365 365
                 $extra = array('subject' => $subject);
366 366
                 $this->messagingService->sendMessage($this, $message, $author, array_merge($arguments, $extra));
@@ -369,19 +369,19 @@  discard block
 block discarded – undo
369 369
 
370 370
         // Filter recipients based on group
371 371
         $recipients = $this->getConfigSetting('Recipients');
372
-        if (is_array($recipients) && $recipientGroup !== 'all') {
372
+        if(is_array($recipients) && $recipientGroup !== 'all') {
373 373
             $recipients = isset($recipients[$recipientGroup])
374 374
                 ? $recipients[$recipientGroup]
375 375
                 : null;
376 376
         }
377
-        if (empty($recipients)) {
377
+        if(empty($recipients)) {
378 378
             $this->log("Skipping sending message to empty recipients");
379 379
             return;
380 380
         }
381 381
 
382 382
         // Send to recipients
383 383
         list($subject, $message) = $this->generateMessageTemplate(self::ROLE_RECIPIENT, $messageID);
384
-        if ($subject && $message && $recipients) {
384
+        if($subject && $message && $recipients) {
385 385
             $recipientsStr = is_array($recipients) ? implode(',', $recipients) : $recipients;
386 386
             $this->log("{$this->Title} sending $messageID message to $recipientsStr");
387 387
             $extra = array('subject' => $subject);
@@ -393,7 +393,7 @@  discard block
 block discarded – undo
393 393
     {
394 394
 
395 395
         // Don't show options if this step has already been confirmed
396
-        if ($this->hasResponse() || !$this->isRunning()) {
396
+        if($this->hasResponse() || !$this->isRunning()) {
397 397
             return;
398 398
         }
399 399
 
@@ -403,7 +403,7 @@  discard block
 block discarded – undo
403 403
     public function allowedActions()
404 404
     {
405 405
         // Don't show options if this step has already been confirmed or can't be confirmed
406
-        if ($this->hasResponse() || !$this->isRunning() || !$this->canApprove()) {
406
+        if($this->hasResponse() || !$this->isRunning() || !$this->canApprove()) {
407 407
             return parent::allowedActions();
408 408
         }
409 409
 
Please login to merge, or discard this patch.
code/queuereport/ResqueJob.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -68,7 +68,7 @@
 block discarded – undo
68 68
      */
69 69
     public function __get($property)
70 70
     {
71
-        if (isset($this->record[$property])) {
71
+        if(isset($this->record[$property])) {
72 72
             return $this->record[$property];
73 73
         }
74 74
         return null;
Please login to merge, or discard this patch.
code/queuereport/ResqueQueue.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -55,16 +55,16 @@  discard block
 block discarded – undo
55 55
         $jobs = new ArrayList();
56 56
 
57 57
         $resqueJobs = Resque::redis()->lrange('queue:' . $this->Name, 0, -1);
58
-        if (!$resqueJobs) {
58
+        if(!$resqueJobs) {
59 59
             $jobs->push(new ResqueJob(array(
60 60
                 'Name' => 'null',
61 61
                 'Value' => 'null',
62 62
             )));
63 63
             return $jobs;
64 64
         }
65
-        foreach ($resqueJobs as $idx => $job) {
65
+        foreach($resqueJobs as $idx => $job) {
66 66
             $stdClass = json_decode($job);
67
-            if ($stdClass->class === 'CapistranoDeploy' || $stdClass->class === 'DeployJob') {
67
+            if($stdClass->class === 'CapistranoDeploy' || $stdClass->class === 'DeployJob') {
68 68
                 $value = $stdClass->args[0]->projectName
69 69
                     . ':' . $stdClass->args[0]->environment
70 70
                     . ' - ' . $stdClass->args[0]->sha;
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
      */
122 122
     public function __get($property)
123 123
     {
124
-        if (isset($this->record[$property])) {
124
+        if(isset($this->record[$property])) {
125 125
             return $this->record[$property];
126 126
         }
127 127
         return null;
Please login to merge, or discard this patch.
code/queuereport/ResqueReport.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -56,7 +56,7 @@
 block discarded – undo
56 56
     {
57 57
         $queues = Resque::queues();
58 58
         $queueList = new ArrayList();
59
-        foreach ($queues as $idx => $queue) {
59
+        foreach($queues as $idx => $queue) {
60 60
             $queueList->push(new ResqueQueue(array(
61 61
                 'ID' => ($idx + 1),
62 62
                 'Name' => $queue,
Please login to merge, or discard this patch.
code/tasks/DNMigrate1_1to1_2.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -12,11 +12,11 @@  discard block
 block discarded – undo
12 12
     {
13 13
         $projects = DNProject::get();
14 14
 
15
-        foreach ($projects as $project) {
15
+        foreach($projects as $project) {
16 16
             $environments = $project->DNEnvironmentList();
17
-            foreach ($environments as $environment) {
17
+            foreach($environments as $environment) {
18 18
                 $newFilename = basename($environment->Filename);
19
-                if ($environment->Filename != $newFilename) {
19
+                if($environment->Filename != $newFilename) {
20 20
                     echo 'Migrating "' . $environment->Filename . '" to ' . $newFilename . PHP_EOL;
21 21
                     $environment->Filename = $newFilename;
22 22
                     $environment->write();
@@ -26,13 +26,13 @@  discard block
 block discarded – undo
26 26
 
27 27
         $warnings = false;
28 28
         // Check if all project folders exists
29
-        foreach ($projects as $project) {
30
-            if (!$project->projectFolderExists()) {
29
+        foreach($projects as $project) {
30
+            if(!$project->projectFolderExists()) {
31 31
                 $warnings = true;
32 32
                 echo 'Project ' . $project->Name . ' don\'t have a cap project folder' . PHP_EOL;
33 33
             }
34 34
         }
35
-        if ($warnings) {
35
+        if($warnings) {
36 36
             exit(1);
37 37
         }
38 38
     }
Please login to merge, or discard this patch.
code/tasks/SyncProjectsAndEnvironments.php 1 patch
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -11,15 +11,15 @@  discard block
 block discarded – undo
11 11
         $remove = true;
12 12
         $dryRun = true;
13 13
 
14
-        if ($request && $request->requestVar('remove') !== null) {
14
+        if($request && $request->requestVar('remove') !== null) {
15 15
             $remove = (bool)$request->requestVar('remove');
16 16
         }
17 17
 
18
-        if ($request && $request->requestVar('dryrun') !== null) {
18
+        if($request && $request->requestVar('dryrun') !== null) {
19 19
             $dryRun = (bool)$request->requestVar('dryrun');
20 20
         }
21 21
 
22
-        if ($dryRun) {
22
+        if($dryRun) {
23 23
             echo "Running in dry run mode, no changes commited, ";
24 24
             echo "the output shows a prediction on what will happen." . PHP_EOL;
25 25
             echo "To skip dryrun, run the task like this:" . PHP_EOL;
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
 
33 33
         // Sync projects
34 34
         $projects = DNProject::get();
35
-        if ($remove) {
35
+        if($remove) {
36 36
             $this->echoHeader('Removing obsolete projects');
37 37
             $this->removeObsoleteProjects($projectPaths, $dryRun);
38 38
         }
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
         $this->syncProjectPaths($projectPaths, $dryRun);
41 41
 
42 42
         $this->echoHeader('Syncing environment files');
43
-        foreach ($projects as $project) {
43
+        foreach($projects as $project) {
44 44
             $this->echoHeader($project->Name);
45 45
             // Sync environments for each project
46 46
             $environmentPaths = $data->getEnvironmentPaths($project->Name);
@@ -60,18 +60,18 @@  discard block
 block discarded – undo
60 60
     {
61 61
         $list = $project->Environments();
62 62
 
63
-        $basePaths = array_map(function ($path) {
63
+        $basePaths = array_map(function($path) {
64 64
             return basename($path);
65 65
         }, $paths);
66 66
 
67 67
         $removeList = $list->filter('Filename:not', $basePaths);
68
-        if ($removeList->count() === 0) {
68
+        if($removeList->count() === 0) {
69 69
             return;
70 70
         }
71 71
 
72
-        foreach ($removeList as $remove) {
72
+        foreach($removeList as $remove) {
73 73
             $this->message('Removing "' . basename($remove->Name) . '" from db');
74
-            if (!$dryRun) {
74
+            if(!$dryRun) {
75 75
                 $removeList->remove($remove);
76 76
             }
77 77
         }
@@ -87,13 +87,13 @@  discard block
 block discarded – undo
87 87
     protected function removeObsoleteProjects($paths, $dryrun = false)
88 88
     {
89 89
         $removeList = DNProject::get()->filter('Name:not', $paths);
90
-        if ($removeList->count() == 0) {
90
+        if($removeList->count() == 0) {
91 91
             return;
92 92
         }
93 93
 
94
-        foreach ($removeList as $remove) {
94
+        foreach($removeList as $remove) {
95 95
             $this->message($remove->Name . ' ' . $remove->Path);
96
-            if (!$dryrun) {
96
+            if(!$dryrun) {
97 97
                 $removeList->remove($remove);
98 98
             }
99 99
         }
@@ -111,22 +111,22 @@  discard block
 block discarded – undo
111 111
         $list = $project->Environments();
112 112
 
113 113
         // Normalise paths in DB
114
-        foreach ($list as $item) {
114
+        foreach($list as $item) {
115 115
             $real = realpath($item->Filename);
116
-            if ($real && $real != $item->Filename) {
116
+            if($real && $real != $item->Filename) {
117 117
                 $item->Filename = $real;
118 118
                 $item->write();
119 119
             }
120 120
         }
121 121
 
122
-        foreach ($paths as $path) {
122
+        foreach($paths as $path) {
123 123
             $path = basename($path);
124
-            if ($list->filter('Filename', $path)->count()) {
124
+            if($list->filter('Filename', $path)->count()) {
125 125
                 continue;
126 126
             }
127 127
 
128 128
             $this->message('Adding "' . basename($path) . '" to db');
129
-            if (!$dryRun) {
129
+            if(!$dryRun) {
130 130
                 $environment = DNEnvironment::create_from_path($path);
131 131
                 $environment->ProjectID = $project->ID;
132 132
                 $environment->write();
@@ -142,10 +142,10 @@  discard block
 block discarded – undo
142 142
      */
143 143
     public function syncProjectPaths($paths, $dryRun = false)
144 144
     {
145
-        foreach ($paths as $path) {
146
-            if (!DNProject::get()->filter('Name', $path)->count()) {
145
+        foreach($paths as $path) {
146
+            if(!DNProject::get()->filter('Name', $path)->count()) {
147 147
                 $this->message($path);
148
-                if (!$dryRun) {
148
+                if(!$dryRun) {
149 149
                     DNProject::create_from_path($path)->write();
150 150
                 }
151 151
             }
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
      */
158 158
     protected function message($text)
159 159
     {
160
-        if (PHP_SAPI !== 'cli') {
160
+        if(PHP_SAPI !== 'cli') {
161 161
             $text = '<p>' . $text . '</p>' . PHP_EOL;
162 162
         }
163 163
         echo ' - ' . $text . PHP_EOL;
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
      */
169 169
     protected function echoHeader($text)
170 170
     {
171
-        if (PHP_SAPI !== 'cli') {
171
+        if(PHP_SAPI !== 'cli') {
172 172
             echo '<h2>' . $text . '</h2>' . PHP_EOL;
173 173
         } else {
174 174
             echo '# ' . $text . PHP_EOL;
Please login to merge, or discard this patch.