}
@Override
protected void checkSingleRecord(WarningRecord record, File logFile, WarningDetector warningDetector) throws MojoExecutionException {
WarningRecord oldCount = oldWarningCountFor(record);
boolean readOnly = (operationMode == OperationMode.CHECK);
if (oldCount == null) {
if (readOnly) {
getLog().warn(String.format("Unable to obtain old warning count for %s; may be first run of this artifact version. New count would be %s", record.source(), record.warningCount()));
} else {
getLog().info(String.format("Unable to obtain old warning count for %s; may be first run of this artifact version. New count is %s", record.source(), record.warningCount()));
recordWarningCountInDatabase(record);
}
}
else if (record.warningCount() < oldCount.warningCount()) {
getLog().info(String.format("Well done! Warning count for %s decreased from %s to %s", record.source(), oldCount.warningCount(), record.warningCount()));
if (!readOnly) {
recordWarningCountInDatabase(record);
}
} else if (oldCount.warningCount() == record.warningCount()) {
getLog().info(String.format("Warning count for %s remains steady at %s", record.source(), record.warningCount()));
} else {
String diff = generateDiff(oldCount, record);
if (operationMode == OperationMode.FORCE) {
getLog().warn(String.format("Against my better judgement, forcing warning count increase for %s from %s to %s; new warnings:\n%s", record.source(), oldCount.warningCount(), record.warningCount(), diff));
recordWarningCountInDatabase(record);
} else {
getLog().error(String.format("Failing build with increase for %s from %s to %s; changed warnings:\n%s", record.source(), oldCount.warningCount(), record.warningCount(), diff));
addFailure(String.format("Failing build with %s warning count %s higher than previous mark of %s; see %s for warning details", record.source(), record.warningCount(), oldCount.warningCount(), logFile));
}
}
}