Passed
Push — master ( 68e144...a80af2 )
by Nicolaas
02:07
created

LintAll::hasCommitAndPush()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

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

35
            foreach ($this->mu()->/** @scrutinizer ignore-call */ getExistingModuleDirLocations() as $moduleDir) {
Loading history...
36
                $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

36
                $this->mu()->/** @scrutinizer ignore-call */ execMe(
Loading history...
37
                    $this->mu()->getWebRootDirLocation(),
0 ignored issues
show
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

37
                    $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

37
                    $this->mu()->/** @scrutinizer ignore-call */ getWebRootDirLocation(),
Loading history...
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

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