diff --git a/pom.xml b/pom.xml index 0ac6ef5..7f3b5d1 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ edu.hm.hafner codingstyle-pom - 3.42.0 + 4.0.1 diff --git a/src/main/java/edu/hm/hafner/grading/AggregatedScore.java b/src/main/java/edu/hm/hafner/grading/AggregatedScore.java index 1a150f6..059a25a 100644 --- a/src/main/java/edu/hm/hafner/grading/AggregatedScore.java +++ b/src/main/java/edu/hm/hafner/grading/AggregatedScore.java @@ -30,7 +30,7 @@ * @author Eva-Maria Zeintl * @author Ullrich Hafner */ -@SuppressWarnings({"PMD.GodClass", "PMD.CyclomaticComplexity", "PMD.ExcessivePublicCount"}) +@SuppressWarnings({"PMD.GodClass", "PMD.CyclomaticComplexity", "PMD.ExcessivePublicCount", "PMD.CouplingBetweenObjects"}) public final class AggregatedScore implements Serializable { @Serial private static final long serialVersionUID = 3L; diff --git a/src/main/java/edu/hm/hafner/grading/AutoGradingRunner.java b/src/main/java/edu/hm/hafner/grading/AutoGradingRunner.java index 2c3fe4e..d91898d 100644 --- a/src/main/java/edu/hm/hafner/grading/AutoGradingRunner.java +++ b/src/main/java/edu/hm/hafner/grading/AutoGradingRunner.java @@ -21,6 +21,8 @@ public class AutoGradingRunner { private static final String SINGLE_LINE = "--------------------------------------------------------------------------------"; private static final String DOUBLE_LINE = "================================================================================"; + private static final int ERROR_CAPACITY = 1024; + private final PrintStream outputStream; /** @@ -154,7 +156,7 @@ protected void publishError(final AggregatedScore score, final FilteredLog log, */ protected String createErrorMessageMarkdown(final FilteredLog log) { if (log.hasErrors()) { - var errors = new StringBuilder(); + var errors = new StringBuilder(ERROR_CAPACITY); errors.append("## :construction: Error Messages\n```\n"); var messages = new StringJoiner("\n"); @@ -184,7 +186,7 @@ private String readDefaultConfiguration() { var name = getDefaultConfigurationPath(); try (var defaultConfig = AutoGradingRunner.class.getResourceAsStream(name)) { if (defaultConfig == null) { - throw new IOException("Can't find configuration in class path: " + name); + throw new IllegalStateException("Can't find configuration in class path: " + name); } return new String(defaultConfig.readAllBytes(), StandardCharsets.UTF_8); } diff --git a/src/main/java/edu/hm/hafner/grading/CoverageConfiguration.java b/src/main/java/edu/hm/hafner/grading/CoverageConfiguration.java index 1bac360..d337da1 100644 --- a/src/main/java/edu/hm/hafner/grading/CoverageConfiguration.java +++ b/src/main/java/edu/hm/hafner/grading/CoverageConfiguration.java @@ -76,7 +76,7 @@ public int getMissedPercentageImpact() { * code coverage */ public boolean isMutationCoverage() { - return StringUtils.containsAnyIgnoreCase(getId() + getName(), CoverageConfiguration.MUTATION_IDS); + return StringUtils.containsAnyIgnoreCase(getId() + getName(), MUTATION_IDS); } @Override diff --git a/src/main/java/edu/hm/hafner/grading/CoverageMarkdown.java b/src/main/java/edu/hm/hafner/grading/CoverageMarkdown.java index 173f081..689c585 100644 --- a/src/main/java/edu/hm/hafner/grading/CoverageMarkdown.java +++ b/src/main/java/edu/hm/hafner/grading/CoverageMarkdown.java @@ -66,8 +66,8 @@ protected void createSpecificDetails(final AggregatedScore aggregation, final Li private String getImageForScoreOrCoverage(final CoverageScore score) { if (score.hasMaxScore()) { // show the score percentage - return ScoreMarkdown.getPercentageImage(score.getDisplayName(), score.getPercentage()); + return getPercentageImage(score.getDisplayName(), score.getPercentage()); } - return ScoreMarkdown.getPercentageImage(score.getDisplayName(), score.getCoveredPercentage()); + return getPercentageImage(score.getDisplayName(), score.getCoveredPercentage()); } } diff --git a/src/test/java/edu/hm/hafner/grading/AnalysisScoreTest.java b/src/test/java/edu/hm/hafner/grading/AnalysisScoreTest.java index e28ef3e..62644e7 100644 --- a/src/test/java/edu/hm/hafner/grading/AnalysisScoreTest.java +++ b/src/test/java/edu/hm/hafner/grading/AnalysisScoreTest.java @@ -36,15 +36,7 @@ void shouldCalculateImpactAndScoreWithNegativeValues() { } """); - var analysisScore = new AnalysisScoreBuilder() - .withId(ID) - .withName(NAME) - .withConfiguration(configuration) - .withReport(createReportWith(Severity.ERROR, Severity.ERROR, - Severity.WARNING_HIGH, Severity.WARNING_HIGH, - Severity.WARNING_NORMAL, Severity.WARNING_NORMAL, - Severity.WARNING_LOW, Severity.WARNING_LOW)) - .build(); + var analysisScore = createScore(configuration); assertThat(analysisScore) .hasId(ID).hasName(NAME).hasConfiguration(configuration) .hasErrorSize(2).hasHighSeveritySize(2).hasNormalSeveritySize(2).hasLowSeveritySize(2) @@ -76,7 +68,18 @@ void shouldCalculateImpactAndScoreWithPositiveValues() { } """); - var analysisScore = new AnalysisScoreBuilder() + var analysisScore = createScore(configuration); + assertThat(analysisScore) + .hasId(ID).hasName(NAME).hasConfiguration(configuration) + .hasErrorSize(2).hasHighSeveritySize(2).hasNormalSeveritySize(2).hasLowSeveritySize(2) + .hasMaxScore(25) + .hasTotalSize(2 + 2 + 2 + 2) + .hasImpact(2 * 4 + 2 * 3 + 2 * 2 + 2) + .hasValue(20); + } + + private AnalysisScore createScore(final AnalysisConfiguration configuration) { + return new AnalysisScoreBuilder() .withId(ID) .withName(NAME) .withConfiguration(configuration) @@ -85,13 +88,6 @@ void shouldCalculateImpactAndScoreWithPositiveValues() { Severity.WARNING_NORMAL, Severity.WARNING_NORMAL, Severity.WARNING_LOW, Severity.WARNING_LOW)) .build(); - assertThat(analysisScore) - .hasId(ID).hasName(NAME).hasConfiguration(configuration) - .hasErrorSize(2).hasHighSeveritySize(2).hasNormalSeveritySize(2).hasLowSeveritySize(2) - .hasMaxScore(25) - .hasTotalSize(2 + 2 + 2 + 2) - .hasImpact(2 * 4 + 2 * 3 + 2 * 2 + 2) - .hasValue(20); } @Test