CheckSecurityCommand::configure()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 10
rs 9.4285
cc 1
eloc 4
nc 1
nop 0
1
<?php
2
3
namespace Yoghi\Bundle\MaddaBundle\Command;
4
5
use Psr\Log\LoggerInterface;
6
use SensioLabs\Security\SecurityChecker;
7
use Symfony\Component\Console\Command\Command;
8
use Symfony\Component\Console\Input\InputInterface;
9
use Symfony\Component\Console\Output\OutputInterface;
10
use Symfony\Component\Console\Style\SymfonyStyle;
11
12
class CheckSecurityCommand extends Command
13
{
14
    private $logger;
15
    // private $errors;
16
17
    public function __construct(LoggerInterface $logger = null)
18
    {
19
        $this->logger = $logger;
20
        parent::__construct();
21
    }
22
23
    protected function configure()
24
    {
25
        $this
26
            ->setName('security:check')
27
            ->setDescription('security check')
28
            // ->addArgument('srcfile', InputArgument::REQUIRED, 'File xml sorgente')
0 ignored issues
show
Unused Code Comprehensibility introduced by
58% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
29
            // ->addArgument('tipologia', InputArgument::REQUIRED, 'Tipologia delle sessioni')
0 ignored issues
show
Unused Code Comprehensibility introduced by
58% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
30
            // ->addOption('clean', null, InputOption::VALUE_OPTIONAL, 'Option clean output directory')
0 ignored issues
show
Unused Code Comprehensibility introduced by
59% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
31
        ;
32
    }
33
34
    protected function execute(InputInterface $input, OutputInterface $output)
35
    {
36
        $io = new SymfonyStyle($input, $output);
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $io. Configured minimum length is 3.

Short variable names may make your code harder to understand. Variable names should be self-descriptive. This check looks for variable names who are shorter than a configured minimum.

Loading history...
37
        $io->title('Secuirty Check');
38
39
        $fileName = __DIR__.'composer.lock';
40
41
        if ($this->logger) {
42
            $this->logger->info('Start security check on '.$fileName);
43
        }
44
45
        //@see: https://github.com/sensiolabs/security-checker
46
        $checker = new SecurityChecker();
47
        $alerts = $checker->check('composer.lock');
48
49
        count($alerts) > 0 ? $io->error($alerts) : $io->success('security checked!');
50
    }
51
}
52