Scrutinizer GitHub App not installed

We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.

Install GitHub App

Passed
Push — add-update-command ( 3eac9b )
by Pedro
15:29
created

DetectEditorAddonRequirementsStep::run()   B

Complexity

Conditions 7
Paths 15

Size

Total Lines 42
Code Lines 23

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 7
eloc 23
c 1
b 0
f 1
nc 15
nop 0
dl 0
loc 42
rs 8.6186
1
<?php
2
3
namespace Backpack\CRUD\app\Console\Commands\Upgrade\v7\Steps;
4
5
use Backpack\CRUD\app\Console\Commands\Upgrade\Step;
6
use Backpack\CRUD\app\Console\Commands\Upgrade\StepResult;
7
8
class DetectEditorAddonRequirementsStep extends Step
9
{
10
    protected array $editors = [
11
        'ckeditor' => 'backpack/ckeditor-field',
12
        'tinymce' => 'backpack/tinymce-field',
13
    ];
14
15
    public function title(): string
16
    {
17
        return 'Ensure rich text editor add-ons are installed';
18
    }
19
20
    public function run(): StepResult
21
    {
22
        $matches = $this->context()->searchTokens(array_keys($this->editors));
23
        $issues = [];
24
25
        foreach ($this->editors as $keyword => $package) {
26
            $paths = $matches[$keyword] ?? [];
27
28
            if (empty($paths)) {
29
                continue;
30
            }
31
32
            if ($this->context()->hasComposerPackage($package)) {
33
                continue;
34
            }
35
36
            $preview = array_slice($paths, 0, 10);
37
            $details = array_map(fn ($path) => "- {$keyword} usage: {$path}", $preview);
38
39
            if (count($paths) > count($preview)) {
40
                $details[] = sprintf('… %d more occurrence(s) omitted.', count($paths) - count($preview));
41
            }
42
43
            $issues[] = [
44
                'summary' => sprintf('Install %s to keep using the %s field/column.', $package, $keyword),
45
                'details' => $details,
46
            ];
47
        }
48
49
        if (empty($issues)) {
50
            return StepResult::success('No missing editor add-ons detected.');
51
        }
52
53
        $summary = 'Install the missing editor packages listed below.';
54
        $detailLines = [];
55
56
        foreach ($issues as $issue) {
57
            $detailLines[] = $issue['summary'];
58
            $detailLines = array_merge($detailLines, $issue['details']);
59
        }
60
61
        return StepResult::warning($summary, $detailLines);
62
    }
63
}
64