Passed
Branch master (2f7647)
by Nicolaas
04:56 queued 03:20
created

InspectAPIChanges   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 58
Duplicated Lines 0 %

Importance

Changes 3
Bugs 1 Features 0
Metric Value
wmc 6
eloc 27
c 3
b 1
f 0
dl 0
loc 58
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A runActualTask() 0 24 3
A getDescription() 0 3 1
A hasCommitAndPush() 0 3 1
A getTitle() 0 3 1
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 = [])
44
    {
45
        $this->mu()->execMe(
46
            $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

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
        foreach ($this->mu()->findNameSpaceAndCodeDirs() as $baseNameSpace => $codeDir) {
53
            if($this->mu->getIsModuleUpgrade()) {
54
                $dirToRun = $codeDir;
55
            } else {
56
                $dirToRun = dirname($codeDir);
57
                $rootDir = '';
58
            }
59
            $this->runSilverstripeUpgradeTask(
60
                'inspect',
61
                $this->param1 = $dirToRun,
62
                $this->param2 = '',
63
                $rootDir,
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $rootDir does not seem to be defined for all execution paths leading up to this point.
Loading history...
64
                $this->settings
65
            );
66
            $this->setCommitMessage('MAJOR: core upgrade to SS4: running INSPECT on ' . $this->param1);
67
        }
68
    }
69
70
    protected function hasCommitAndPush()
71
    {
72
        return true;
73
    }
74
}
75