Skip to content

The Unified and Autonomous Development Platform

Still record metrics even if there is no checkstyle violations

Robin Shen5df5c75592e8
diff --git a/server-plugin/server-plugin-report-checkstyle/src/main/java/org/server/plugin/report/checkstyle/JobCheckstyleReport.java b/server-plugin/server-plugin-report-checkstyle/src/main/java/org/server/plugin/report/checkstyle/JobCheckstyleReport.java
index 3c7f8837c8..4e77d63058 100644
--- a/server-plugin/server-plugin-report-checkstyle/src/main/java/org/server/plugin/report/checkstyle/JobCheckstyleReport.java
+++ b/server-plugin/server-plugin-report-checkstyle/src/main/java/org/server/plugin/report/checkstyle/JobCheckstyleReport.java
@@ -77,6 +77,7 @@ public class JobCheckstyleReport extends JobReport {
List<CheckstyleViolation> violations = new ArrayList<>();
+ boolean hasReports = false;
for (File file: getPatternSet().listFiles(workspace)) {
logger.log("Processing checkstyle report: " + file.getAbsolutePath().substring(baseLen));
Document doc = reader.read(file);
@@ -105,14 +106,18 @@ public class JobCheckstyleReport extends JobReport {
}
}
}
+ hasReports = true;
}
- return new CheckstyleReportData(violations);
+ if (hasReports)
+ return new CheckstyleReportData(violations);
+ else
+ return null;
}
});
- if (!reportData.getViolations().isEmpty()) {
+ if (reportData != null) {
FileUtils.createDir(reportDir);
reportData.writeTo(reportDir);