Skip to content

Commit 472ed5a

Browse files
authored
remove unnecessary I/O indirections (#119)
* remove unnecessary code * remove unneeded override
1 parent f3e9603 commit 472ed5a

File tree

4 files changed

+14
-32
lines changed

4 files changed

+14
-32
lines changed

src/test/java/org/apache/maven/plugins/checkstyle/AbstractCheckstyleTestCase.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public abstract class AbstractCheckstyleTestCase extends AbstractMojoTestCase {
4444
private ArtifactStubFactory artifactStubFactory;
4545

4646
/**
47-
* The current project to be test.
47+
* The project to test.
4848
*/
4949
private MavenProject testMavenProject;
5050

@@ -80,9 +80,9 @@ protected MavenProject getTestMavenProject() {
8080
/**
8181
* Get the generated report as file in the test maven project.
8282
*
83-
* @param name the name of the report.
83+
* @param name the name of the report
8484
* @return the generated report as file
85-
* @throws IOException if the return file doesnt exist
85+
* @throws IOException if the return file doesn't exist
8686
*/
8787
protected File getGeneratedReport(String name) throws IOException {
8888
String outputDirectory = getBasedir() + "/target/test/test-harness/"

src/test/java/org/apache/maven/plugins/checkstyle/stubs/MinMavenProjectStub.java

+4-10
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
import org.apache.maven.model.Build;
2828
import org.apache.maven.model.Organization;
2929
import org.apache.maven.model.ReportPlugin;
30-
import org.codehaus.plexus.PlexusTestCase;
3130

3231
/**
3332
* @author Edwin Punzalan
@@ -42,27 +41,22 @@ public List<String> getCompileClasspathElements() throws DependencyResolutionReq
4241
/** {@inheritDoc} */
4342
public List<String> getTestClasspathElements() throws DependencyResolutionRequiredException {
4443
List<String> list = new ArrayList<>(getCompileClasspathElements());
45-
list.add(PlexusTestCase.getBasedir() + "/target/test-classes");
44+
list.add("target/test-classes");
4645
return list;
4746
}
4847

4948
/** {@inheritDoc} */
5049
public List<String> getCompileSourceRoots() {
51-
return Collections.singletonList(PlexusTestCase.getBasedir() + "/target/classes");
50+
return Collections.singletonList("target/classes");
5251
}
5352

5453
/** {@inheritDoc} */
5554
public List<String> getTestCompileSourceRoots() {
5655
List<String> list = new ArrayList<>(getCompileSourceRoots());
57-
list.add(PlexusTestCase.getBasedir() + "/target/test-classes");
56+
list.add("target/test-classes");
5857
return list;
5958
}
6059

61-
/** {@inheritDoc} */
62-
public File getBasedir() {
63-
return new File(PlexusTestCase.getBasedir());
64-
}
65-
6660
/** {@inheritDoc} */
6761
public List<ReportPlugin> getReportPlugins() {
6862
ReportPlugin jxrPlugin = new ReportPlugin();
@@ -90,7 +84,7 @@ public String getInceptionYear() {
9084
public Build getBuild() {
9185
Build build = new Build();
9286

93-
build.setDirectory(PlexusTestCase.getBasedir() + "/target/test-harness/checkstyle/min");
87+
build.setDirectory("target/test-harness/checkstyle/min");
9488

9589
return build;
9690
}

src/test/java/org/apache/maven/plugins/checkstyle/stubs/ModuleMavenProjectStub.java

+6-12
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
import org.apache.maven.model.Build;
2828
import org.apache.maven.model.Organization;
2929
import org.apache.maven.model.ReportPlugin;
30-
import org.codehaus.plexus.PlexusTestCase;
3130

3231
/**
3332
* @author Edwin Punzalan
@@ -43,27 +42,22 @@ public List<String> getCompileClasspathElements() throws DependencyResolutionReq
4342
/** {@inheritDoc} */
4443
public List<String> getTestClasspathElements() throws DependencyResolutionRequiredException {
4544
List<String> list = new ArrayList<>(getCompileClasspathElements());
46-
list.add(PlexusTestCase.getBasedir() + "/target/test-classes");
45+
list.add("target/test-classes");
4746
return list;
4847
}
4948

5049
/** {@inheritDoc} */
5150
public List<String> getCompileSourceRoots() {
52-
return Collections.singletonList(PlexusTestCase.getBasedir() + "/target/classes");
51+
return Collections.singletonList("target/classes");
5352
}
5453

5554
/** {@inheritDoc} */
5655
public List<String> getTestCompileSourceRoots() {
5756
List<String> list = new ArrayList<>(getCompileSourceRoots());
58-
list.add(PlexusTestCase.getBasedir() + "/target/test-classes");
57+
list.add("target/test-classes");
5958
return list;
6059
}
6160

62-
/** {@inheritDoc} */
63-
public File getBasedir() {
64-
return new File(PlexusTestCase.getBasedir());
65-
}
66-
6761
/** {@inheritDoc} */
6862
public List<ReportPlugin> getReportPlugins() {
6963
ReportPlugin jxrPlugin = new ReportPlugin();
@@ -91,9 +85,9 @@ public String getInceptionYear() {
9185
public Build getBuild() {
9286
Build build = new Build();
9387

94-
build.setDirectory(PlexusTestCase.getBasedir() + "/target/test-harness/checkstyle/multi");
95-
build.setSourceDirectory(PlexusTestCase.getBasedir() + "/src/test/test-sources");
96-
build.setTestSourceDirectory(PlexusTestCase.getBasedir() + "/src/test/java");
88+
build.setDirectory("target/test-harness/checkstyle/multi");
89+
build.setSourceDirectory("src/test/test-sources");
90+
build.setTestSourceDirectory("src/test/java");
9791

9892
return build;
9993
}

src/test/java/org/apache/maven/plugins/checkstyle/stubs/MultiMavenProjectStub.java

+1-7
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
import org.apache.maven.model.Organization;
2828
import org.apache.maven.model.ReportPlugin;
2929
import org.apache.maven.project.MavenProject;
30-
import org.codehaus.plexus.PlexusTestCase;
3130

3231
/**
3332
*
@@ -63,11 +62,6 @@ public List<String> getTestCompileSourceRoots() {
6362
return Collections.emptyList();
6463
}
6564

66-
/** {@inheritDoc} */
67-
public File getBasedir() {
68-
return new File(PlexusTestCase.getBasedir());
69-
}
70-
7165
/** {@inheritDoc} */
7266
public List<ReportPlugin> getReportPlugins() {
7367
ReportPlugin jxrPlugin = new ReportPlugin();
@@ -95,7 +89,7 @@ public String getInceptionYear() {
9589
public Build getBuild() {
9690
Build build = new Build();
9791

98-
build.setDirectory(PlexusTestCase.getBasedir() + "/target/test-harness/checkstyle/multi");
92+
build.setDirectory("target/test-harness/checkstyle/multi");
9993

10094
return build;
10195
}

0 commit comments

Comments
 (0)