FixOutdatedPHPStyles   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 55
Duplicated Lines 0 %

Importance

Changes 3
Bugs 0 Features 0
Metric Value
wmc 5
eloc 28
c 3
b 0
f 0
dl 0
loc 55
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A hasCommitAndPush() 0 3 1
A getDescription() 0 3 1
A getTitle() 0 3 1
A runActualTask() 0 33 2
1
<?php
2
3
namespace Sunnysideup\UpgradeToSilverstripe4\Tasks\IndividualTasks;
4
5
use Sunnysideup\UpgradeToSilverstripe4\Tasks\Task;
6
7
class FixOutdatedPHPStyles extends Task
8
{
9
    protected $taskStep = 's10';
10
11
    protected $composerOptions = '';
12
13
    public function getTitle()
14
    {
15
        return 'Uses sunnysideup/huringa to check for outdated styles. An important part of this is to separate files into separate files / classes.';
16
    }
17
18
    public function getDescription()
19
    {
20
        return '
21
            See huringa module for mor details';
22
    }
23
24
    public function runActualTask($params = []): ?string
25
    {
26
        $webRoot = $this->mu()->getWebRootDirLocation();
0 ignored issues
show
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

26
        $webRoot = $this->mu()->/** @scrutinizer ignore-call */ 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

26
        $webRoot = $this->mu()->/** @scrutinizer ignore-call */ getWebRootDirLocation();
Loading history...
27
28
        $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

28
        $this->mu()->/** @scrutinizer ignore-call */ execMe(
Loading history...
29
            $webRoot,
0 ignored issues
show
Bug introduced by
It seems like $webRoot 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

29
            /** @scrutinizer ignore-type */ $webRoot,
Loading history...
30
            'composer require --dev --with-all-dependencies sunnysideup/huringa:dev-master --no-interaction',
31
            'installing huringa',
32
            false
33
        );
34
35
        $codeDirs = $this->mu()->findNameSpaceAndCodeDirs();
36
        $this->mu()->setBreakOnAllErrors(true);
37
        foreach ($codeDirs as $codeDir) {
38
            $this->mu()->execMe(
39
                $webRoot,
40
                'vendor/bin/huringa ' . $codeDir,
41
                'fixing outdated code styles in ' . $codeDir,
42
                false
43
            );
44
45
            $this->setCommitMessage('API:  fixing outdated code styles using sunnysideup/huringa in ' . $codeDir);
46
        }
47
48
        $this->mu()->execMe(
49
            $webRoot,
50
            'composer remove sunnysideup/huringa:dev-master',
51
            'uninstalling huringa',
52
            false
53
        );
54
55
        $this->mu()->setBreakOnAllErrors(false);
56
        return null;
57
    }
58
59
    protected function hasCommitAndPush()
60
    {
61
        return true;
62
    }
63
}
64