InspectAPIChanges::hasCommitAndPush()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
c 0
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\UpgradeToSilverstripe4\Tasks\Task;
6
7
/**
8
 * Runs the silverstripe/upgrade task "inspect". See:
9
 * https://github.com/silverstripe/silverstripe-upgrader#inspect.
10
 * Once a project has all class names migrated, and is brought up to a
11
 * "loadable" state (that is, where all classes reference or extend real classes)
12
 * then the inspect command can be run to perform additional automatic code rewrites.
13
 * This step will also warn of any upgradable code issues that may prevent a succesful upgrade.
14
 */
15
class InspectAPIChanges extends Task
16
{
17
    protected $taskStep = 's50';
18
19
    protected $param1 = '';
20
21
    protected $param2 = '';
22
23
    protected $rootDirForCommand = '';
24
25
    protected $settings = '';
26
27
    public function getTitle()
28
    {
29
        return 'After load fixes (inspect)';
30
    }
31
32
    public function getDescription()
33
    {
34
        return '
35
            Runs the silverstripe/upgrade task "inspect". See:
36
            https://github.com/silverstripe/silverstripe-upgrader#inspect.
37
            Once a project has all class names migrated, and is brought up to a
38
            "loadable" state (that is, where all classes reference or extend real classes)
39
            then the inspect command can be run to perform additional automatic code rewrites.
40
            This step will also warn of any upgradable code issues that may prevent a succesful upgrade.';
41
    }
42
43
    public function runActualTask($params = []): ?string
44
    {
45
        $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

45
        $this->mu()->/** @scrutinizer ignore-call */ execMe(
Loading history...
46
            $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

46
            /** @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

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

46
            $this->mu()->/** @scrutinizer ignore-call */ getWebRootDirLocation(),
Loading history...
47
            'composer dump-autoload',
48
            'run composer dump-autoload to create autoload classes',
49
            false
50
        );
51
52
        $this->mu()->setBreakOnAllErrors(true);
53
54
        foreach ($this->mu()->findNameSpaceAndCodeDirs() as $codeDir) {
55
            $rootDir = '';
56
            if ($this->mu()->getIsModuleUpgrade()) {
57
                $dirToRun = $codeDir;
58
            } else {
59
                $dirToRun = dirname($codeDir);
60
            }
61
            $this->runSilverstripeUpgradeTask(
62
                'inspect',
63
                $this->param1 = $dirToRun,
64
                $this->param2 = '',
65
                $rootDir,
66
                $this->settings
67
            );
68
            $this->setCommitMessage('API:  core upgrade to SS4: running INSPECT on ' . $this->param1);
69
        }
70
71
        $this->mu()->setBreakOnAllErrors(false);
72
        return null;
73
    }
74
75
    protected function hasCommitAndPush()
76
    {
77
        return true;
78
    }
79
}
80