From 9c23bfb19e82d7057b5d86dda81e2c58d6622b50 Mon Sep 17 00:00:00 2001 From: Elliotte Rusty Harold Date: Thu, 21 Nov 2024 05:04:39 -0500 Subject: [PATCH 1/3] Remove unused code --- .../checkstyle/AbstractCheckstyleReport.java | 15 ++++----------- .../checkstyle/CheckstyleViolationCheckMojo.java | 3 +-- .../plugins/checkstyle/CheckstyleReportTest.java | 2 -- 3 files changed, 5 insertions(+), 15 deletions(-) diff --git a/src/main/java/org/apache/maven/plugins/checkstyle/AbstractCheckstyleReport.java b/src/main/java/org/apache/maven/plugins/checkstyle/AbstractCheckstyleReport.java index 4ab9e052..d5f01ead 100644 --- a/src/main/java/org/apache/maven/plugins/checkstyle/AbstractCheckstyleReport.java +++ b/src/main/java/org/apache/maven/plugins/checkstyle/AbstractCheckstyleReport.java @@ -58,7 +58,6 @@ import org.codehaus.plexus.resource.ResourceManager; import org.codehaus.plexus.resource.loader.FileResourceLoader; import org.codehaus.plexus.util.FileUtils; -import org.codehaus.plexus.util.PathTool; /** * Base abstract class for Checkstyle reports. @@ -461,11 +460,13 @@ public abstract class AbstractCheckstyleReport extends AbstractMavenReport { protected ByteArrayOutputStream stringOutputStream; /** {@inheritDoc} */ + @Override public String getName(Locale locale) { return getI18nString(locale, "name"); } /** {@inheritDoc} */ + @Override public String getDescription(Locale locale) { return getI18nString(locale, "description"); } @@ -479,6 +480,7 @@ protected String getI18nString(Locale locale, String key) { return i18n.getString("checkstyle-report", locale, "report.checkstyle." + key); } + @Override protected MavenProject getProject() { return project; } @@ -488,6 +490,7 @@ protected List getReactorProjects() { } /** {@inheritDoc} */ + @Override public void executeReport(Locale locale) throws MavenReportException { checkDeprecatedParameterUsage(sourceDirectory, "sourceDirectory", "sourceDirectories"); checkDeprecatedParameterUsage(testSourceDirectory, "testSourceDirectory", "testSourceDirectories"); @@ -675,16 +678,6 @@ protected AuditListener getConsoleListener() throws MavenReportException { return consoleListener; } - private String determineRelativePath(File location) { - String relativePath = - PathTool.getRelativePath(getReportOutputDirectory().getAbsolutePath(), location.getAbsolutePath()); - if (relativePath == null || relativePath.trim().isEmpty()) { - relativePath = "."; - } - - return relativePath + "/" + location.getName(); - } - protected List getSourceDirectories() { if (sourceDirectories == null) { sourceDirectories = filterBuildTarget(project.getCompileSourceRoots()); diff --git a/src/main/java/org/apache/maven/plugins/checkstyle/CheckstyleViolationCheckMojo.java b/src/main/java/org/apache/maven/plugins/checkstyle/CheckstyleViolationCheckMojo.java index 21a9802d..218fc27c 100644 --- a/src/main/java/org/apache/maven/plugins/checkstyle/CheckstyleViolationCheckMojo.java +++ b/src/main/java/org/apache/maven/plugins/checkstyle/CheckstyleViolationCheckMojo.java @@ -485,11 +485,10 @@ public class CheckstyleViolationCheckMojo extends AbstractMojo { @Parameter(property = "checkstyle.excludeGeneratedSources", defaultValue = "false") private boolean excludeGeneratedSources; - private AuditListener auditListener; - private File outputXmlFile; /** {@inheritDoc} */ + @Override public void execute() throws MojoExecutionException, MojoFailureException { checkDeprecatedParameterUsage(sourceDirectory, "sourceDirectory", "sourceDirectories"); checkDeprecatedParameterUsage(testSourceDirectory, "testSourceDirectory", "testSourceDirectories"); diff --git a/src/test/java/org/apache/maven/plugins/checkstyle/CheckstyleReportTest.java b/src/test/java/org/apache/maven/plugins/checkstyle/CheckstyleReportTest.java index 038839b1..a2009aab 100644 --- a/src/test/java/org/apache/maven/plugins/checkstyle/CheckstyleReportTest.java +++ b/src/test/java/org/apache/maven/plugins/checkstyle/CheckstyleReportTest.java @@ -135,8 +135,6 @@ private void generateReport(String pluginXml) throws Exception { assertTrue("Test cache file exists", new File(cacheFile).exists()); } - File outputDir = mojo.getReportOutputDirectory(); - File useFile = (File) getVariableValueFromObject(mojo, "useFile"); if (useFile != null) { assertTrue("Test useFile exists", useFile.exists()); From 1870fbb797317876c1891f13cde7e2e0eb797b7e Mon Sep 17 00:00:00 2001 From: Elliotte Rusty Harold Date: Thu, 21 Nov 2024 05:11:44 -0500 Subject: [PATCH 2/3] fix --- .../apache/maven/plugins/checkstyle/CheckstyleReportTest.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/test/java/org/apache/maven/plugins/checkstyle/CheckstyleReportTest.java b/src/test/java/org/apache/maven/plugins/checkstyle/CheckstyleReportTest.java index a2009aab..ba85a81c 100644 --- a/src/test/java/org/apache/maven/plugins/checkstyle/CheckstyleReportTest.java +++ b/src/test/java/org/apache/maven/plugins/checkstyle/CheckstyleReportTest.java @@ -135,6 +135,7 @@ private void generateReport(String pluginXml) throws Exception { assertTrue("Test cache file exists", new File(cacheFile).exists()); } + File outputDir = mojo.getReportOutputDirectory(); File useFile = (File) getVariableValueFromObject(mojo, "useFile"); if (useFile != null) { assertTrue("Test useFile exists", useFile.exists()); From 83be0e376479aa08f7597876c454ae7d287784cf Mon Sep 17 00:00:00 2001 From: Elliotte Rusty Harold Date: Thu, 21 Nov 2024 05:32:40 -0500 Subject: [PATCH 3/3] fix --- .../apache/maven/plugins/checkstyle/CheckstyleReportTest.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/test/java/org/apache/maven/plugins/checkstyle/CheckstyleReportTest.java b/src/test/java/org/apache/maven/plugins/checkstyle/CheckstyleReportTest.java index ba85a81c..038839b1 100644 --- a/src/test/java/org/apache/maven/plugins/checkstyle/CheckstyleReportTest.java +++ b/src/test/java/org/apache/maven/plugins/checkstyle/CheckstyleReportTest.java @@ -136,6 +136,7 @@ private void generateReport(String pluginXml) throws Exception { } File outputDir = mojo.getReportOutputDirectory(); + File useFile = (File) getVariableValueFromObject(mojo, "useFile"); if (useFile != null) { assertTrue("Test useFile exists", useFile.exists());