Skip to content

Commit

Permalink
feature #65 Add default counts to zero for every category/severity (t…
Browse files Browse the repository at this point in the history
…galopin)

This PR was merged into the 1.4.x-dev branch.

Discussion
----------

Add default counts to zero for every category/severity

Commits
-------

0115cd5 Add default counts to zero for every category/severity
  • Loading branch information
lyrixx committed Jun 14, 2017
2 parents ec9f40b + 0115cd5 commit 545d0f8
Showing 1 changed file with 25 additions and 17 deletions.
42 changes: 25 additions & 17 deletions Cli/Helper/FailConditionHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,25 +26,33 @@ public function __construct()

public function evaluate(Analysis $analysis, $expr)
{
$counts = array();

$violations = $analysis->getViolations();
if ($violations) {
foreach ($violations as $violation) {
if (!isset($counts[$violation->getCategory()])) {
$counts[$violation->getCategory()] = 0;
}
++$counts[$violation->getCategory()];

if (!isset($counts[$violation->getSeverity()])) {
$counts[$violation->getSeverity()] = 0;
}
++$counts[$violation->getSeverity()];
}
$counts = array(
// Category
'architecture' => 0,
'bugrisk' => 0,
'codestyle' => 0,
'deadcode' => 0,
'performance' => 0,
'readability' => 0,
'security' => 0,

// Severity
'critical' => 0,
'major' => 0,
'minor' => 0,
'info' => 0,
);

$violations = $analysis->getViolations() ?: array();

foreach ($violations as $violation) {
++$counts[$violation->getCategory()];
++$counts[$violation->getSeverity()];
}

$vars = array(
'analysis' => $analysis,
'counts' => (object) $counts,
'analysis' => $analysis,
'counts' => (object) $counts,
);

if ($this->el->evaluate($expr, $vars)) {
Expand Down

0 comments on commit 545d0f8

Please sign in to comment.