Conditions | 3 |
Paths | 3 |
Total Lines | 19 |
Code Lines | 11 |
Lines | 0 |
Ratio | 0 % |
Tests | 12 |
CRAP Score | 3 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
46 | 2 | public function process(File $file, Report $report) { |
|
47 | |||
48 | 2 | $process = new Process(sprintf('composer validate %s', $file->getPath())); |
|
49 | 2 | $process->run(); |
|
50 | |||
51 | 2 | if ($process->isSuccessful()) { |
|
52 | 1 | return; |
|
53 | } |
||
54 | |||
55 | |||
56 | 1 | $errorOutput = $process->getErrorOutput(); |
|
57 | 1 | preg_match('!Parse error on line (\d+):!', $errorOutput, $matchedLine); |
|
58 | 1 | $line = 1; |
|
59 | 1 | if (isset($matchedLine[1])) { |
|
60 | 1 | $line = (int) $matchedLine[1]; |
|
61 | } |
||
62 | |||
63 | 1 | $report->addMessage($file, $this, 'Invalid composer.json file format', $line); |
|
64 | 1 | } |
|
65 | |||
66 | } |