GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( 99078a...9605c1 )
by Oanh
02:49
created

SeriesExecutor::run()   C

Complexity

Conditions 11
Paths 5

Size

Total Lines 41
Code Lines 25

Duplication

Lines 3
Ratio 7.32 %

Code Coverage

Tests 25
CRAP Score 11.1486

Importance

Changes 3
Bugs 1 Features 1
Metric Value
c 3
b 1
f 1
dl 3
loc 41
ccs 25
cts 28
cp 0.8929
rs 5.2653
cc 11
eloc 25
nc 5
nop 5
crap 11.1486

How to fix   Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
/* (c) Anton Medvedev <[email protected]>
3
 *
4
 * For the full copyright and license information, please view the LICENSE
5
 * file that was distributed with this source code.
6
 */
7
8
namespace Deployer\Executor;
9
10
use Deployer\Console\Output\OutputWatcher;
11
use Deployer\Server\Environment;
12
use Deployer\Task\Context;
13
use Deployer\Task\NonFatalException;
14
15
class SeriesExecutor implements ExecutorInterface
16
{
17
    /**
18
     * {@inheritdoc}
19
     */
20 12
    public function run($tasks, $servers, $environments, $input, $output)
21
    {
22 12
        $output = new OutputWatcher($output);
23 12
        $informer = new Informer($output);
24
25 12
        foreach ($tasks as $task) {
26 12
            $success = true;
27 12
            $informer->startTask($task->getName());
28
29 12
            if ($task->isOnce()) {
30 1
                $task->run(new Context(null, null, $input, $output));
31 1
            } else {
32 12
                foreach ($servers as $serverName => $server) {
33 12
                    if ($task->runOnServer($serverName)) {
34 12
                        $env = isset($environments[$serverName]) ? $environments[$serverName] : $environments[$serverName] = new Environment();
35
36 12 View Code Duplication
                        if (count($task->getOnlyForStage()) > 0 && (!$env->has('stages') || !$task->runForStages($env->get('stages')))) {
1 ignored issue
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
37 1
                            continue;
38
                        }
39
40 12
                        $informer->onServer($serverName);
41
42
                        try {
43 12
                            $task->run(new Context($server, $env, $input, $output));
44 12
                        } catch (NonFatalException $exception) {
45
                            $success = false;
46
                            $informer->taskException($serverName, 'Deployer\Task\NonFatalException', $exception->getMessage());
47
                        }
48
49 12
                        $informer->endOnServer($serverName);
50 12
                    }
51 12
                }
52
            }
53
54 12
            if ($success) {
55 12
                $informer->endTask();
56 12
            } else {
57
                $informer->taskError();
58
            }
59 12
        }
60 12
    }
61
}
62