diff --git a/tmc-plugin/src/fi/helsinki/cs/tmc/actions/RunTestsLocallyAction.java b/tmc-plugin/src/fi/helsinki/cs/tmc/actions/RunTestsLocallyAction.java index 1efdd881..cfdbb61a 100644 --- a/tmc-plugin/src/fi/helsinki/cs/tmc/actions/RunTestsLocallyAction.java +++ b/tmc-plugin/src/fi/helsinki/cs/tmc/actions/RunTestsLocallyAction.java @@ -70,10 +70,16 @@ protected boolean enabledFor(Exercise exercise) { @Override public void run() { Exercise exercise = exerciseForProject(project); - if (exercise != null) { - ResultCollector resultCollector = new ResultCollector(exercise); + if (exercise == null) { + return; + } + + ResultCollector resultCollector = new ResultCollector(exercise); + + if (exercise.isCheckstyleEnabled()) { this.checkstyleRunHandler.performAction(resultCollector, project); - this.testRunHandler.performAction(resultCollector, project); } + + this.testRunHandler.performAction(resultCollector, project); } } diff --git a/tmc-plugin/src/fi/helsinki/cs/tmc/data/Exercise.java b/tmc-plugin/src/fi/helsinki/cs/tmc/data/Exercise.java index 7164bfd2..a9ca6755 100644 --- a/tmc-plugin/src/fi/helsinki/cs/tmc/data/Exercise.java +++ b/tmc-plugin/src/fi/helsinki/cs/tmc/data/Exercise.java @@ -65,7 +65,21 @@ public enum ValgrindStrategy { NONE, @SerializedName("fail") FAIL - } + } + + @SerializedName("checkstyle_strategy") + private CheckstyleStrategy checkstyleStrategy = CheckstyleStrategy.DISABLED; + + public enum CheckstyleStrategy { + @SerializedName("disabled") + DISABLED, + @SerializedName("none") + NONE, + @SerializedName("warn") + WARN, + @SerializedName("fail") + FAIL + } public Exercise() { } @@ -264,7 +278,15 @@ public void setRuntimeParams(String[] runtimeParams) { public ValgrindStrategy getValgrindStrategy() { return valgrindStrategy; } + + public CheckstyleStrategy getCheckstyleStrategy() { + return checkstyleStrategy; + } + public boolean isCheckstyleEnabled() { + return checkstyleStrategy.equals(CheckstyleStrategy.FAIL) || checkstyleStrategy.equals(CheckstyleStrategy.WARN); + } + public boolean isCodeReviewRequestsEnabled() { return codeReviewRequestsEnabled; }