LintAll::runActualTask()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 15
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 10
c 1
b 0
f 0
dl 0
loc 15
rs 9.9332
cc 3
nc 3
nop 1
1
<?php
2
3
namespace Sunnysideup\UpgradeToSilverstripe4\Tasks\IndividualTasks;
4
5
use Sunnysideup\PHP2CommandLine\PHP2CommandLineSingleton;
6
use Sunnysideup\UpgradeToSilverstripe4\Tasks\Task;
7
8
/**
9
 * This task adds a legacy branch to the git repo of the original to act as a backup/legacy version for
10
 * holding a version of the module before it was changed
11
 */
12
class LintAll extends Task
13
{
14
    protected $taskStep = 's30';
15
16
    public function getTitle()
17
    {
18
        return 'Lint all php code.';
19
    }
20
21
    public function getDescription()
22
    {
23
        return '
24
            Goes through all the folders and uses the sake-lint-all function (this will need to be installed).';
25
    }
26
27
    /**
28
     * [runActualTask description]
29
     * @param  array  $params not currently used for this task
30
     */
31
    public function runActualTask($params = []): ?string
32
    {
33
        if (PHP2CommandLineSingleton::commandExists('sake-lint-all')) {
34
            foreach ($this->mu()->getExistingModuleDirLocations() as $moduleDir) {
0 ignored issues
show
Bug introduced by
It seems like getExistingModuleDirLocations() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

34
            foreach ($this->mu()->/** @scrutinizer ignore-call */ getExistingModuleDirLocations() as $moduleDir) {
Loading history...
35
                $this->mu()->execMe(
0 ignored issues
show
Bug introduced by
It seems like execMe() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

35
                $this->mu()->/** @scrutinizer ignore-call */ execMe(
Loading history...
36
                    $this->mu()->getWebRootDirLocation(),
0 ignored issues
show
Bug introduced by
It seems like $this->mu()->getWebRootDirLocation() can also be of type Sunnysideup\UpgradeToSilverstripe4\ModuleUpgrader and Sunnysideup\UpgradeToSilverstripe4\Traits\Creator and null; however, parameter $newDir of Sunnysideup\UpgradeToSil...oduleUpgrader::execMe() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

36
                    /** @scrutinizer ignore-type */ $this->mu()->getWebRootDirLocation(),
Loading history...
Bug introduced by
The method getWebRootDirLocation() does not exist on Sunnysideup\UpgradeToSilverstripe4\ModuleUpgrader. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

36
                    $this->mu()->/** @scrutinizer ignore-call */ getWebRootDirLocation(),
Loading history...
Bug introduced by
It seems like getWebRootDirLocation() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

36
                    $this->mu()->/** @scrutinizer ignore-call */ getWebRootDirLocation(),
Loading history...
37
                    'sake-lint-all ' . $moduleDir,
38
                    'Linting all PHP files in ' . $moduleDir,
39
                    true
40
                );
41
            }
42
        } else {
43
            return 'You need to install sake-lint-all to use this task: https://github.com/sunnysideup/silverstripe-easy-coding-standards';
44
        }
45
        return null;
46
    }
47
48
    protected function hasCommitAndPush()
49
    {
50
        return true;
51
    }
52
}
53