@@ -74,7 +74,7 @@ |
||
74 | 74 | EOT; |
75 | 75 | |
76 | 76 | /** |
77 | - * @param RuleInterface[] $rules |
|
77 | + * @param RuleFilterIterator $rules |
|
78 | 78 | * @param string $htmlFile |
79 | 79 | */ |
80 | 80 | public static function generateHtmlFile(RuleFilterIterator $rules, $htmlFile) |
@@ -10,7 +10,6 @@ |
||
10 | 10 | |
11 | 11 | namespace ProjectQualityInspector\Application\Output; |
12 | 12 | |
13 | -use ProjectQualityInspector\Exception\RuleViolationException; |
|
14 | 13 | use ProjectQualityInspector\Iterator\RuleFilterIterator; |
15 | 14 | |
16 | 15 | class HtmlReportHelper |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | */ |
99 | 99 | private static function createTestSuite($name, array $tests) |
100 | 100 | { |
101 | - $testSuite = '<h2> '.strtoupper($name).', tests: '.count($tests).' failures: '.static::sumArraysKey('failures', $tests, 'sum').', errors: '.static::sumArraysKey('errors', $tests, 'sum').', time: '.static::sumArraysKey('time', $tests).'</h2>'; |
|
101 | + $testSuite = '<h2> ' . strtoupper($name) . ', tests: ' . count($tests) . ' failures: ' . static::sumArraysKey('failures', $tests, 'sum') . ', errors: ' . static::sumArraysKey('errors', $tests, 'sum') . ', time: ' . static::sumArraysKey('time', $tests) . '</h2>'; |
|
102 | 102 | |
103 | 103 | $testSuite .= '<table class="testsuite"> |
104 | 104 | <tr> |
@@ -133,8 +133,8 @@ discard block |
||
133 | 133 | if ($test['failures']['sum'] > 0) { |
134 | 134 | foreach ($test['failures']['list'] as $failure) { |
135 | 135 | $testCase .= '<tr class="failure"> |
136 | - <td>'.$failure['type'].'</td> |
|
137 | - <td>'.self::sanitizeTags($failure['message']).'</td> |
|
136 | + <td>'.$failure['type'] . '</td> |
|
137 | + <td>'.self::sanitizeTags($failure['message']) . '</td> |
|
138 | 138 | </tr>'; |
139 | 139 | } |
140 | 140 | } |
@@ -142,8 +142,8 @@ discard block |
||
142 | 142 | if ($test['errors']['sum'] > 0) { |
143 | 143 | foreach ($test['errors']['list'] as $error) { |
144 | 144 | $testCase .= '<tr class="error"> |
145 | - <td>'.$error['type'].'</td> |
|
146 | - <td>'.self::sanitizeTags($error['message']).'</td> |
|
145 | + <td>'.$error['type'] . '</td> |
|
146 | + <td>'.self::sanitizeTags($error['message']) . '</td> |
|
147 | 147 | </tr>'; |
148 | 148 | } |
149 | 149 | } |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | class JunitHelper |
17 | 17 | { |
18 | 18 | /** |
19 | - * @param RuleInterface[] $rules |
|
19 | + * @param RuleFilterIterator $rules |
|
20 | 20 | * @param string $junitFile |
21 | 21 | */ |
22 | 22 | public static function generateJunitFile(RuleFilterIterator $rules, $junitFile) |
@@ -40,8 +40,8 @@ discard block |
||
40 | 40 | |
41 | 41 | /** |
42 | 42 | * @param array $tests |
43 | - * @param DOMDocument $xml |
|
44 | - * @return DOMDocument |
|
43 | + * @param \DOMDocument $xml |
|
44 | + * @return \DOMElement |
|
45 | 45 | */ |
46 | 46 | private static function createTestSuite($name, array $tests, \DOMDocument $xml) |
47 | 47 | { |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | * @param array $attributes |
90 | 90 | * @param \DOMDocument $xml |
91 | 91 | * @param string $value |
92 | - * @return \DOMDocument |
|
92 | + * @return \DOMElement |
|
93 | 93 | */ |
94 | 94 | private static function createElement($tagName, array $attributes, \DOMDocument $xml, $value = null) |
95 | 95 | { |
@@ -10,7 +10,6 @@ |
||
10 | 10 | |
11 | 11 | namespace ProjectQualityInspector\Application\Output; |
12 | 12 | |
13 | -use ProjectQualityInspector\Exception\RuleViolationException; |
|
14 | 13 | use ProjectQualityInspector\Iterator\RuleFilterIterator; |
15 | 14 | |
16 | 15 | class JunitHelper |
@@ -28,10 +28,10 @@ |
||
28 | 28 | $testSuites->appendChild(static::createTestSuite($rule::getRuleName(), $rule->getAssertions(), $xml)); |
29 | 29 | } |
30 | 30 | |
31 | - $testSuites->setAttribute('name', 'pqi'); |
|
32 | - $testSuites->setAttribute('errors', static::sumDomChildsAttribute($testSuites, 'errors')); |
|
33 | - $testSuites->setAttribute('failures', static::sumDomChildsAttribute($testSuites, 'failures')); |
|
34 | - $testSuites->setAttribute('time', static::sumDomChildsAttribute($testSuites, 'time')); |
|
31 | + $testSuites->setAttribute('name', 'pqi'); |
|
32 | + $testSuites->setAttribute('errors', static::sumDomChildsAttribute($testSuites, 'errors')); |
|
33 | + $testSuites->setAttribute('failures', static::sumDomChildsAttribute($testSuites, 'failures')); |
|
34 | + $testSuites->setAttribute('time', static::sumDomChildsAttribute($testSuites, 'time')); |
|
35 | 35 | |
36 | 36 | $xml->appendChild($testSuites); |
37 | 37 |
@@ -191,7 +191,7 @@ |
||
191 | 191 | /** |
192 | 192 | * @param string $version |
193 | 193 | * |
194 | - * @return mixed |
|
194 | + * @return string |
|
195 | 195 | */ |
196 | 196 | protected function sanitizeVersion($version) |
197 | 197 | { |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | |
53 | 53 | /** |
54 | 54 | * @param $fileConf |
55 | - * @param $baseDir |
|
55 | + * @param string $baseDir |
|
56 | 56 | * @return array |
57 | 57 | */ |
58 | 58 | private function expectsFilesGlobExists($fileConf, $baseDir) |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | } |
76 | 76 | |
77 | 77 | /** |
78 | - * @param $filePathGlob |
|
78 | + * @param string $filePathGlob |
|
79 | 79 | * @param $reason |
80 | 80 | * @return array |
81 | 81 | * |
@@ -307,14 +307,14 @@ |
||
307 | 307 | */ |
308 | 308 | private function explodeCommitsArrays(array $commits) |
309 | 309 | { |
310 | - $explodedCommits = []; |
|
310 | + $explodedCommits = []; |
|
311 | 311 | |
312 | - foreach ($commits as $commit) { |
|
313 | - $explodedCommit = explode('|', $commit); |
|
314 | - $explodedCommit = array_combine(array_slice($this->commitFormatKeys, 0, count($explodedCommit)), $explodedCommit); |
|
315 | - $explodedCommits[$explodedCommit['commitHash']] = $explodedCommit; |
|
316 | - } |
|
312 | + foreach ($commits as $commit) { |
|
313 | + $explodedCommit = explode('|', $commit); |
|
314 | + $explodedCommit = array_combine(array_slice($this->commitFormatKeys, 0, count($explodedCommit)), $explodedCommit); |
|
315 | + $explodedCommits[$explodedCommit['commitHash']] = $explodedCommit; |
|
316 | + } |
|
317 | 317 | |
318 | - return $explodedCommits; |
|
318 | + return $explodedCommits; |
|
319 | 319 | } |
320 | 320 | } |
321 | 321 | \ No newline at end of file |
@@ -96,17 +96,17 @@ discard block |
||
96 | 96 | $commonAncestorCommitInfo = $this->getMergeBaseCommit($notMergedBranchInfo['branchName'], $stableBranch); |
97 | 97 | $stableBranchLastCommitInfo = $this->getBranchLastCommitInfo($stableBranch); |
98 | 98 | |
99 | - if ($lrAheadCommitsCount[$stableBranch] >= (int)$this->config['threshold-commits-behind']) { |
|
99 | + if ($lrAheadCommitsCount[$stableBranch] >= (int) $this->config['threshold-commits-behind']) { |
|
100 | 100 | $failed = true; |
101 | 101 | } |
102 | 102 | |
103 | 103 | $interval = $this->compareCommitInfosDatesDiff($commonAncestorCommitInfo, $stableBranchLastCommitInfo); |
104 | - if ((int)$interval->format('%r%a') >= (int)$this->config['threshold-days-behind']) { |
|
104 | + if ((int) $interval->format('%r%a') >= (int) $this->config['threshold-days-behind']) { |
|
105 | 105 | $failed = true; |
106 | 106 | } |
107 | 107 | |
108 | 108 | if ($failed) { |
109 | - $message = sprintf('The branch <fg=green>%s</> is behind <fg=green>%s</> by %s commits spread through %s days.', $notMergedBranchInfo['branchName'], $stableBranch, $lrAheadCommitsCount[$stableBranch], (int)$interval->format('%r%a')); |
|
109 | + $message = sprintf('The branch <fg=green>%s</> is behind <fg=green>%s</> by %s commits spread through %s days.', $notMergedBranchInfo['branchName'], $stableBranch, $lrAheadCommitsCount[$stableBranch], (int) $interval->format('%r%a')); |
|
110 | 110 | $message .= sprintf(' <fg=green>%s</> should update the branch %s', $notMergedBranchInfo['authorName'], $notMergedBranchInfo['branchName']); |
111 | 111 | throw new ExpectationFailedException($notMergedBranchInfo, $message); |
112 | 112 | } |
@@ -279,8 +279,8 @@ discard block |
||
279 | 279 | $branchesRegex = ['^$']; |
280 | 280 | |
281 | 281 | if (is_array($this->config[$configKey]) && count($this->config[$configKey])) { |
282 | - $branchesRegex = array_map(function ($element) { |
|
283 | - return '\(^[ ]*'.$element.'$\)'; |
|
282 | + $branchesRegex = array_map(function($element) { |
|
283 | + return '\(^[ ]*' . $element . '$\)'; |
|
284 | 284 | }, $this->config[$configKey]); |
285 | 285 | } |
286 | 286 |
@@ -26,7 +26,7 @@ |
||
26 | 26 | * @param \Iterator $iterator |
27 | 27 | * @param array $ruleNames |
28 | 28 | */ |
29 | - public function __construct(\Iterator $iterator , array $ruleNames = []) |
|
29 | + public function __construct(\Iterator $iterator, array $ruleNames = []) |
|
30 | 30 | { |
31 | 31 | parent::__construct($iterator); |
32 | 32 | $this->ruleNames = $ruleNames; |
@@ -45,7 +45,7 @@ |
||
45 | 45 | $output->writeln(sprintf('<error>%s: KO</error>', $rule::getRuleName())); |
46 | 46 | |
47 | 47 | foreach ($e->getExpectationFailedExceptions() as $expectationFailedException) { |
48 | - $reason = ($expectationFailedException->getReason()) ? sprintf(' Reason: %s', $expectationFailedException->getReason()): ''; |
|
48 | + $reason = ($expectationFailedException->getReason()) ? sprintf(' Reason: %s', $expectationFailedException->getReason()) : ''; |
|
49 | 49 | $output->writeln(sprintf('<comment>Expectation failed: %s.%s</comment>', $expectationFailedException->getMessage(), $reason)); |
50 | 50 | } |
51 | 51 | } |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | |
75 | 75 | /** |
76 | 76 | * @param array $expectedResponse |
77 | - * @param array $response |
|
77 | + * @param Response $response |
|
78 | 78 | * |
79 | 79 | * @throws ExpectationFailedException |
80 | 80 | */ |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | |
98 | 98 | /** |
99 | 99 | * @param array $expectedResponse |
100 | - * @param array $response |
|
100 | + * @param Response $response |
|
101 | 101 | * |
102 | 102 | * @throws ExpectationFailedException |
103 | 103 | */ |
@@ -10,7 +10,6 @@ |
||
10 | 10 | |
11 | 11 | namespace ProjectQualityInspector\Rule; |
12 | 12 | |
13 | -use ProjectQualityInspector\Application\ProcessHelper; |
|
14 | 13 | use ProjectQualityInspector\Exception\ExpectationFailedException; |
15 | 14 | use GuzzleHttp\Psr7\Request; |
16 | 15 | use GuzzleHttp\Psr7\Response; |