Skip to content

Commit 870ef1b

Browse files
author
Vincent Potucek
committed
RemoveUnusedPrivateMethods
1 parent 678f0aa commit 870ef1b

File tree

3 files changed

+50
-1
lines changed

3 files changed

+50
-1
lines changed

pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/private_method_in_inner_class_interface1.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,20 @@ public class PrivateMethodsInInterface1 {
1515

1616
public interface Interface1 {
1717
Object FOO = new Object() {
18+
private void privateMethod() { }
1819
};
1920
}
2021

2122
public interface Interface2 {
2223
class InnerClass {
24+
private void privateMethod() { }
2325
}
2426
}
2527

2628
public interface Interface3 {
2729
enum InnerEnum {
2830
VALUE;
31+
private void privateMethod() { }
2932
}
3033
}
3134
}

pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/ast/jdkversiontests/private_method_in_inner_class_interface2.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,21 @@ public class PrivateMethodsInInterface2 {
1414

1515
public interface Interface1 {
1616
Object FOO = new Object() {
17-
}; // note: this will be a parser error!
17+
private void privateMethod() { }
18+
};
19+
private void privateMethodInInterface1() { } // note: this will be a parser error!
1820
}
1921

2022
public interface Interface2 {
2123
class InnerClass {
24+
private void privateMethod() { }
2225
}
2326
}
2427

2528
public interface Interface3 {
2629
enum InnerEnum {
2730
VALUE;
31+
private void privateMethod() { }
2832
}
2933
}
3034
}

pom.xml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,48 @@
134134
<build>
135135
<pluginManagement>
136136
<plugins>
137+
<plugin>
138+
<groupId>org.openrewrite.maven</groupId>
139+
<artifactId>rewrite-maven-plugin</artifactId>
140+
<version>6.8.0</version>
141+
<configuration>
142+
<activeRecipes>
143+
<!-- BestPractices -->
144+
<!-- <recipe>org.openrewrite.java.recipes.JavaRecipeBestPractices</recipe> -->
145+
<!-- <recipe>org.openrewrite.java.recipes.RecipeNullabilityBestPractices</recipe> -->
146+
<!-- <recipe>org.openrewrite.java.recipes.RecipeTestingBestPractices</recipe> -->
147+
<!-- testing -->
148+
<!-- <recipe>org.openrewrite.java.testing.assertj.JUnitToAssertj</recipe> -->
149+
<!-- <recipe>org.openrewrite.java.testing.assertj.SimplifyAssertJAssertion</recipe> -->
150+
<!-- <recipe>org.openrewrite.java.testing.junit5.JUnit5BestPractices</recipe> -->
151+
<!-- staticanalysis -->
152+
<!-- <recipe>org.openrewrite.staticanalysis.CodeCleanup</recipe> -->
153+
<!-- <recipe>org.openrewrite.staticanalysis.CommonStaticAnalysis</recipe> -->
154+
<!-- <recipe>org.openrewrite.staticanalysis.FinalizeMethodArguments</recipe> -->
155+
<!-- <recipe>org.openrewrite.staticanalysis.RemoveUnusedLocalVariables</recipe> -->
156+
<!-- <recipe>org.openrewrite.staticanalysis.RemoveUnusedPrivateFields</recipe> -->
157+
<recipe>org.openrewrite.staticanalysis.RemoveUnusedPrivateMethods</recipe>
158+
</activeRecipes>
159+
<exportDatatables>true</exportDatatables>
160+
<failOnDryRunResults>true</failOnDryRunResults>
161+
</configuration>
162+
<dependencies>
163+
<dependency>
164+
<groupId>org.openrewrite.recipe</groupId>
165+
<artifactId>rewrite-static-analysis</artifactId>
166+
<version>2.9.0</version>
167+
</dependency>
168+
</dependencies>
169+
<executions>
170+
<execution>
171+
<id>rewrite-maven-plugin</id>
172+
<goals>
173+
<goal>dryRun</goal>
174+
</goals>
175+
<phase>verify</phase>
176+
</execution>
177+
</executions>
178+
</plugin>
137179
<plugin>
138180
<groupId>org.antlr</groupId>
139181
<artifactId>antlr4-maven-plugin</artifactId>

0 commit comments

Comments
 (0)