diff --git a/plugin/src/main/groovy/com/novoda/staticanalysis/DefaultViolationsEvaluator.groovy b/plugin/src/main/groovy/com/novoda/staticanalysis/DefaultViolationsEvaluator.groovy index 0beec77..99f8315 100644 --- a/plugin/src/main/groovy/com/novoda/staticanalysis/DefaultViolationsEvaluator.groovy +++ b/plugin/src/main/groovy/com/novoda/staticanalysis/DefaultViolationsEvaluator.groovy @@ -17,22 +17,21 @@ class DefaultViolationsEvaluator implements ViolationsEvaluator { @Override void evaluate(Set allViolations) { - Map total = [errors: 0, warnings: 0] String fullMessage = '' allViolations.each { Violations violations -> if (!violations.isEmpty()) { fullMessage += "> ${getViolationsMessage(violations, reportUrlRenderer)}\n" } } - total['errors'] = allViolations.collect { it.errors }.sum() as int - total['warnings'] = allViolations.collect { it.warnings }.sum() as int + int totalErrors = allViolations.collect { it.errors }.sum() as int + int totalWarnings = allViolations.collect { it.warnings }.sum() as int - int errorsDiff = Math.max(0, total['errors'] - penalty.maxErrors) - int warningsDiff = Math.max(0, total['warnings'] - penalty.maxWarnings) + int errorsDiff = Math.max(0, totalErrors - penalty.maxErrors) + int warningsDiff = Math.max(0, totalWarnings - penalty.maxWarnings) if (errorsDiff > 0 || warningsDiff > 0) { throw new GradleException("Violations limit exceeded by $errorsDiff errors, $warningsDiff warnings.\n\n$fullMessage") } else if (!fullMessage.isEmpty()) { - logger.warn "\n$fullMessage" + logger.warn "\nViolations found ($totalErrors errors, $totalWarnings warnings)\n\n$fullMessage" } } diff --git a/plugin/src/test/groovy/com/novoda/staticanalysis/DefaultViolationsEvaluatorTest.groovy b/plugin/src/test/groovy/com/novoda/staticanalysis/DefaultViolationsEvaluatorTest.groovy index 99438af..d6d42b6 100644 --- a/plugin/src/test/groovy/com/novoda/staticanalysis/DefaultViolationsEvaluatorTest.groovy +++ b/plugin/src/test/groovy/com/novoda/staticanalysis/DefaultViolationsEvaluatorTest.groovy @@ -43,7 +43,9 @@ class DefaultViolationsEvaluatorTest { evaluator.evaluate(allViolations) - def expected = """ + def expected = """ + Violations found (1 errors, 0 warnings) + > $TOOL_NAME violations found (1 errors, 0 warnings). See the reports at: - $consoleClickableFileUrl """