Skip to content

Commit

Permalink
More fixes from PR review
Browse files Browse the repository at this point in the history
  • Loading branch information
adangel committed Jun 6, 2024
1 parent 41aa83e commit d5f616e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,9 @@ private CpdResult run() throws MavenReportException {
// in constrast to pmd goal, we don't have a parameter for cpd like "skipPmdError" - if there
// are any errors during CPD analysis, the maven build fails.
int cpdErrors = cpdConfiguration.getReporter().numErrors();
if (cpdErrors > 0) {
if (cpdErrors == 1) {
throw new MavenReportException("There was 1 error while executing CPD");
} else if (cpdErrors > 1) {
throw new MavenReportException("There were " + cpdErrors + " errors while executing CPD");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ private File writeReport(CPDReport cpd, CPDReportRenderer renderer, String exten

File targetDir = new File(request.getTargetDirectory());
if (!targetDir.exists() && !targetDir.mkdirs()) {
throw new IOException("Could create report output directory " + targetDir);
throw new IOException("Couldn't create report output directory: " + targetDir);
}

File targetFile = new File(targetDir, "cpd." + extension);
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/org/apache/maven/plugins/pmd/CpdReportTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public void testInvalidFormat() throws Exception {

fail("MavenReportException must be thrown");
} catch (Exception e) {
assertMavenReportException("There were 1 errors while executing CPD", e);
assertMavenReportException("There was 1 error while executing CPD", e);
assertLogOutputContains("Can't find CPD custom format xhtml");
}
}
Expand Down Expand Up @@ -247,7 +247,7 @@ public void testWithCpdErrors() throws Exception {
File generatedReport = generateReport("cpd", "CpdReportTest/with-cpd-errors/pom.xml");
fail("MavenReportException must be thrown");
} catch (Exception e) {
assertMavenReportException("There were 1 errors while executing CPD", e);
assertMavenReportException("There was 1 error while executing CPD", e);
assertLogOutputContains("Lexical error in file");
assertLogOutputContains("BadFile.java");
}
Expand Down

0 comments on commit d5f616e

Please sign in to comment.