From 5563cacde3365b3270cd58d97a133181b0a69940 Mon Sep 17 00:00:00 2001 From: Max Miller Date: Sun, 4 Apr 2021 18:21:02 +1000 Subject: [PATCH] Give 0 marks for automated style if Checkstyle exits unsuccessfully Fixes #5 --- src/chalkbox/java/checkstyle/Checkstyle.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/chalkbox/java/checkstyle/Checkstyle.java b/src/chalkbox/java/checkstyle/Checkstyle.java index a43e570..d342285 100644 --- a/src/chalkbox/java/checkstyle/Checkstyle.java +++ b/src/chalkbox/java/checkstyle/Checkstyle.java @@ -180,6 +180,11 @@ public Collection run(Collection collection) { int numViolations = Math.max(0, checkstyleOutput.split("\n").length - 2); + // if Checkstyle didn't exit successfully, give 0 marks for automated style + if (!checkstyleOutput.contains("Audit done.")) { + numViolations = Integer.MAX_VALUE; // many violations -> 0 marks + } + JSONArray tests = (JSONArray) feedback.get("tests"); Data result = new Data(); result.set("name", "Automated Style");