Skip to content

Commit

Permalink
[JENKINS-23185] Setting build status to FAILURE for new error when er…
Browse files Browse the repository at this point in the history
…rors were fixed

- CppcheckBuildResultEvaluator.isErrorCountExceeded() used comparison count > threshold but users expect count >= threshold.
- For example the threshold had to be set to 0 to change build status on 1 new issue. Setting 1 in threshold configuration to detect 1 issue is much better.
- Information in build log extended to contain also the value that exceeded the threshold. Word "errors" replaced by "issues".
  • Loading branch information
mixalturek committed Jul 27, 2014
1 parent 90e1a1f commit cb4e204
Showing 1 changed file with 19 additions and 10 deletions.
Expand Up @@ -17,33 +17,42 @@ public Result evaluateBuildResult(
CppcheckConfigSeverityEvaluation severityEvaluation) {

if (isErrorCountExceeded(errorsCount, severityEvaluation.getFailureThreshold())) {
CppcheckLogger.log(listener, "Setting build status to FAILURE since total number of errors"
+ " exceeds the threshold value '" + severityEvaluation.getFailureThreshold() + "'.");
CppcheckLogger.log(listener,
"Setting build status to FAILURE since total number of issues '"
+ errorsCount + "' exceeds the threshold value '"
+ severityEvaluation.getFailureThreshold() + "'.");
return Result.FAILURE;
}
if (isErrorCountExceeded(newErrorsCount, severityEvaluation.getNewFailureThreshold())) {
CppcheckLogger.log(listener, "Setting build status to FAILURE since total number of new errors"
+ " exceeds the threshold value '" + severityEvaluation.getNewFailureThreshold() + "'.");
CppcheckLogger.log(listener,
"Setting build status to FAILURE since number of new issues '"
+ newErrorsCount + "' exceeds the threshold value '"
+ severityEvaluation.getNewFailureThreshold() + "'.");
return Result.FAILURE;
}
if (isErrorCountExceeded(errorsCount, severityEvaluation.getThreshold())) {
CppcheckLogger.log(listener, "Setting build status to UNSTABLE since total number of errors"
+ " exceeds the threshold value '" + severityEvaluation.getThreshold() + "'.");
CppcheckLogger.log(listener,
"Setting build status to UNSTABLE since total number of issues '"
+ errorsCount + "' exceeds the threshold value '"
+ severityEvaluation.getThreshold() + "'.");
return Result.UNSTABLE;
}
if (isErrorCountExceeded(newErrorsCount, severityEvaluation.getNewThreshold())) {
CppcheckLogger.log(listener, "Setting build status to UNSTABLE since total number of new errors"
+ " exceeds the threshold value '" + severityEvaluation.getNewThreshold() + "'.");
CppcheckLogger.log(listener,
"Setting build status to UNSTABLE since number of new issues '"
+ newErrorsCount + "' exceeds the threshold value '"
+ severityEvaluation.getNewThreshold() + "'.");
return Result.UNSTABLE;
}

CppcheckLogger.log(listener, "Not changing build status, since no threshold has been exceeded");
CppcheckLogger.log(listener,
"Not changing build status, since no threshold has been exceeded.");
return Result.SUCCESS;
}

private boolean isErrorCountExceeded(final int errorCount, final String errorThreshold) {
if (errorCount > 0 && CppcheckMetricUtil.isValid(errorThreshold)) {
return errorCount > CppcheckMetricUtil.convert(errorThreshold);
return errorCount >= CppcheckMetricUtil.convert(errorThreshold);
}
return false;
}
Expand Down

2 comments on commit cb4e204

@iwonbigbro
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The >= change on Line 55. Is that now causing this:
[Cppcheck] Setting build status to UNSTABLE since total number of issues '10585' exceeds the threshold value '10585'.

Note, the two values are the same.

@iwonbigbro
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just retrospectively read the check-in comment at the top of the page. Makes sense I suppose. I will update my thresholds.

Please sign in to comment.