This is an automated email from the ASF dual-hosted git repository.
elharo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-pmd-plugin.git
The following commit(s) were added to refs/heads/master by this push:
new 43c71e8 [MPMD-412] clean up unused code (#190)
43c71e8 is described below
commit 43c71e8b51b3357c0e63fa199e76a8c1ce48b968
Author: Elliotte Rusty Harold <[email protected]>
AuthorDate: Sat Apr 19 19:35:04 2025 +0000
[MPMD-412] clean up unused code (#190)
* clean up unused code
---
.../plugins/pmd/AbstractPmdReportTestCase.java | 74 ++++++----------------
1 file changed, 18 insertions(+), 56 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..2ad4015 100644
--- a/src/test/java/org/apache/maven/plugins/pmd/AbstractPmdReportTestCase.java
+++ b/src/test/java/org/apache/maven/plugins/pmd/AbstractPmdReportTestCase.java
@@ -35,7 +35,6 @@ import org.apache.maven.plugin.testing.ArtifactStubFactory;
import org.apache.maven.plugin.testing.stubs.MavenProjectStub;
import org.apache.maven.project.DefaultProjectBuildingRequest;
import org.apache.maven.project.MavenProject;
-import org.apache.maven.project.ProjectBuilder;
import org.apache.maven.project.ProjectBuildingRequest;
import org.eclipse.aether.DefaultRepositorySystemSession;
import org.eclipse.aether.internal.impl.SimpleLocalRepositoryManagerFactory;
@@ -49,11 +48,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 +58,10 @@ public abstract class AbstractPmdReportTestCase extends
AbstractMojoTestCase {
}
/**
- * Get the current Maven project
+ * Generate the report and return the generated file.
*
- * @return the maven project
- */
- protected MavenProject getTestMavenProject() {
- return testMavenProject;
- }
-
- /**
- * Get the generated report as file in the test maven project.
- *
- * @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
*/
@@ -133,13 +99,9 @@ public abstract class AbstractPmdReportTestCase extends
AbstractMojoTestCase {
protected File generateReport(AbstractPmdReport mojo, File pluginXmlFile)
throws Exception {
mojo.execute();
- ProjectBuilder builder = lookup(ProjectBuilder.class);
-
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,38 +109,38 @@ public abstract class AbstractPmdReportTestCase extends
AbstractMojoTestCase {
}
/**
- * Read the contents of the specified file object into a string
+ * Read the contents of the specified file into a string.
*/
protected String readFile(File file) throws IOException {
return new String(Files.readAllBytes(file.toPath()));
}
/**
- * Checks, whether the string <code>contained</code> is contained in
- * the given <code>text</code> ignoring case.
+ * Checks whether the string <code>contained</code> is contained in
+ * 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();