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
Pull Request — master (#3813)
by Cristian
12:53
created

RequireDevTools   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 79
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 36
c 1
b 0
f 0
dl 0
loc 79
rs 10
wmc 5

1 Method

Rating   Name   Duplication   Size   Complexity  
A handle() 0 53 5
1
<?php
2
3
namespace Backpack\CRUD\app\Console\Commands;
4
5
use File;
6
use Illuminate\Console\Command;
7
use Symfony\Component\Process\Process;
8
9
class RequireDevTools extends Command
10
{
11
    use \Backpack\CRUD\app\Console\Commands\Traits\PrettyCommandOutput;
12
13
    protected $progressBar;
14
15
    /**
16
     * The name and signature of the console command.
17
     *
18
     * @var string
19
     */
20
    protected $signature = 'backpack:devtools:require
21
                                {--debug} : Show process output or not. Useful for debugging.';
22
23
    /**
24
     * The console command description.
25
     *
26
     * @var string
27
     */
28
    protected $description = 'Install DevTools with its requirements on dev.';
29
30
    /**
31
     * Execute the console command.
32
     *
33
     * @return mixed Command-line output
34
     */
35
    public function handle()
36
    {
37
        $this->progressBar = $this->output->createProgressBar(15);
38
        $this->progressBar->minSecondsBetweenRedraws(0);
39
        $this->progressBar->maxSecondsBetweenRedraws(120);
40
        $this->progressBar->setRedrawFrequency(1);
41
42
        $this->progressBar->start();
43
44
        $this->info(' DevTools installation started. Please wait...');
45
        $this->progressBar->advance();
46
47
        // Check if auth exists
48
        $details = null;
49
        $process = new Process(['composer', 'config', 'http-basic.backpackforlaravel.com']);
50
        $process->run(function ($type, $buffer) use (&$details) {
51
            if ($type !== Process::ERR && $buffer !== '') {
52
                $details = json_decode($buffer);
53
            }
54
            $this->progressBar->advance();
55
        });
56
57
        // Create an auth.json file
58
        if (! $details) {
59
            $this->info(' Creating auth.json file with DevTools auth details');
60
61
            $this->line(' (Find your access token details on https://backpackforlaravel.com/user/tokens)');
62
            $username = $this->ask('Access token username');
63
            $password = $this->ask('Access token password');
64
65
            $process = new Process(['composer', 'config', 'http-basic.backpackforlaravel.com', $username, $password]);
66
            $process->run(function ($type, $buffer) {
0 ignored issues
show
Unused Code introduced by
The parameter $buffer is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

66
            $process->run(function ($type, /** @scrutinizer ignore-unused */ $buffer) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
67
                if ($type === Process::ERR) {
68
                    $this->error('Could not write to auth.json file.');
69
                }
70
                $this->progressBar->advance();
71
            });
72
        }
73
74
        // Require package
75
        $process = new Process(['composer', 'require', '--dev', 'backpack/devtools']);
76
        $process->run(function ($type, $buffer) {
0 ignored issues
show
Unused Code introduced by
The parameter $type is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

76
        $process->run(function (/** @scrutinizer ignore-unused */ $type, $buffer) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $buffer is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

76
        $process->run(function ($type, /** @scrutinizer ignore-unused */ $buffer) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
77
            $this->progressBar->advance();
78
        });
79
80
        // Finish
81
        $this->progressBar->finish();
82
        $this->info(' DevTools installation finished.');
83
84
        // DevTools inside installer
85
        $this->info('');
86
        $this->info(' DevTools requirements started. Please wait...');
87
        $this->call('backpack:devtools:install');
88
    }
89
}
90