This is an automated email from the ASF dual-hosted git repository. elharo pushed a commit to branch new_branch_with_a1 in repository https://gitbox.apache.org/repos/asf/maven-pmd-plugin.git
commit 327764cc3f2c35bc5677a1e646a74253d5e6b057 Author: Elliotte Rusty Harold <elh...@ibiblio.org> AuthorDate: Thu Apr 17 10:11:54 2025 -0400 clean up unused code --- .../plugins/pmd/AbstractPmdReportTestCase.java | 69 ++++++---------------- 1 file changed, 17 insertions(+), 52 deletions(-) diff --git a/src/test/java/org/apache/maven/plugins/pmd/AbstractPmdReportTestCase.java b/src/test/java/org/apache/maven/plugins/pmd/AbstractPmdReportTestCase.java index 8b4f5e8..2dce685 100644 --- a/src/test/java/org/apache/maven/plugins/pmd/AbstractPmdReportTestCase.java +++ b/src/test/java/org/apache/maven/plugins/pmd/AbstractPmdReportTestCase.java @@ -49,11 +49,6 @@ import org.eclipse.aether.repository.LocalRepository; public abstract class AbstractPmdReportTestCase extends AbstractMojoTestCase { private ArtifactStubFactory artifactStubFactory; - /** - * The current project to be test. - */ - private MavenProject testMavenProject; - @Override protected void setUp() throws Exception { super.setUp(); @@ -64,38 +59,10 @@ public abstract class AbstractPmdReportTestCase extends AbstractMojoTestCase { } /** - * Get the current Maven project - * - * @return the maven project - */ - protected MavenProject getTestMavenProject() { - return testMavenProject; - } - - /** - * Get the generated report as file in the test maven project. + * Generate the report and return the generated file. * - * @param name the name of the report. - * @return the generated report as file - * @throws IOException if the return file doesnt exist - */ - protected File getGeneratedReport(String name) throws IOException { - String outputDirectory = - getBasedir() + "/target/test/unit/" + getTestMavenProject().getArtifactId(); - - File report = new File(outputDirectory, name); - if (!report.exists()) { - throw new IOException("File not found. Attempted: " + report); - } - - return report; - } - - /** - * Generate the report and return the generated file - * - * @param goal the mojo goal. - * @param pluginXml the name of the xml file in "src/test/resources/plugin-configs/". + * @param goal the mojo goal + * @param pluginXml the name of the xml file in "src/test/resources/plugin-configs/" * @return the generated HTML file * @throws Exception if any */ @@ -138,8 +105,6 @@ public abstract class AbstractPmdReportTestCase extends AbstractMojoTestCase { ProjectBuildingRequest buildingRequest = new DefaultProjectBuildingRequest(); buildingRequest.setRepositorySession(lookup(LegacySupport.class).getRepositorySession()); - testMavenProject = builder.build(pluginXmlFile, buildingRequest).getProject(); - File outputDir = mojo.getReportOutputDirectory(); String filename = mojo.getOutputPath() + ".html"; @@ -147,7 +112,7 @@ public abstract class AbstractPmdReportTestCase extends AbstractMojoTestCase { } /** - * Read the contents of the specified file object into a string + * Read the contents of the specified file object into a string. */ protected String readFile(File file) throws IOException { return new String(Files.readAllBytes(file.toPath())); @@ -155,30 +120,30 @@ public abstract class AbstractPmdReportTestCase extends AbstractMojoTestCase { /** * Checks, whether the string <code>contained</code> is contained in - * the given <code>text</code> ignoring case. + * the given <code>text</code>, ignoring case. * * @param text the string in which the search is executed - * @param contains the string, the should be searched - * @return <code>true</code> if the string is contained, otherwise <code>false</code>. + * @param contains the string to be searched for + * @return <code>true</code> if the text contains the string, otherwise <code>false</code> */ public static boolean lowerCaseContains(String text, String contains) { return text.toLowerCase(Locale.ROOT).contains(contains.toLowerCase(Locale.ROOT)); } private MojoExecution getMockMojoExecution() { - MojoDescriptor md = new MojoDescriptor(); - md.setGoal(getGoal()); + MojoDescriptor mojoDescriptor = new MojoDescriptor(); + mojoDescriptor.setGoal(getGoal()); - MojoExecution me = new MojoExecution(md); + MojoExecution execution = new MojoExecution(mojoDescriptor); - PluginDescriptor pd = new PluginDescriptor(); - Plugin p = new Plugin(); - p.setGroupId("org.apache.maven.plugins"); - p.setArtifactId("maven-pmd-plugin"); - pd.setPlugin(p); - md.setPluginDescriptor(pd); + PluginDescriptor pluginDescriptor = new PluginDescriptor(); + Plugin plugin = new Plugin(); + plugin.setGroupId("org.apache.maven.plugins"); + plugin.setArtifactId("maven-pmd-plugin"); + pluginDescriptor.setPlugin(plugin); + mojoDescriptor.setPluginDescriptor(pluginDescriptor); - return me; + return execution; } protected abstract String getGoal();