Skip to content

Commit f032389

Browse files
PMD files
1 parent ef04b8d commit f032389

File tree

2 files changed

+59
-0
lines changed

2 files changed

+59
-0
lines changed

bad.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
public class BadExample {
2+
3+
private int unusedField;
4+
5+
public BadExample() {
6+
// unnecessary constructor
7+
}
8+
9+
public void DOStuff() {
10+
try {
11+
int FooBar = 1;
12+
System.out.println("Start");
13+
14+
for (int i = 0; i < 30; i++) {
15+
System.out.println("Line " + i);
16+
}
17+
} catch (Exception e) {
18+
// silently ignored
19+
} finally {
20+
return; // forbidden in finally block
21+
}
22+
}
23+
}
24+

ruleset.xml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<ruleset name="CodeRabbit PMD Ruleset"
3+
xmlns="http://pmd.sourceforge.net/ruleset/2.0.0"
4+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5+
xsi:schemaLocation="http://pmd.sourceforge.net/ruleset/2.0.0
6+
http://pmd.sourceforge.net/ruleset_2_0_0.xsd"
7+
description="PMD rules aligned with CodeRabbit standards for general-purpose Java projects.">
8+
9+
<!-- Keep existing valid rules -->
10+
<rule ref="category/java/bestpractices.xml/UnusedPrivateField"/>
11+
<rule ref="category/java/errorprone.xml/EmptyCatchBlock"/>
12+
<rule ref="category/java/errorprone.xml/ReturnFromFinallyBlock"/>
13+
<rule ref="category/java/codestyle.xml/UnnecessaryConstructor"/>
14+
15+
<!-- Replace deprecated VariableNamingConventions with specific naming rules -->
16+
<rule ref="category/java/codestyle.xml/LocalVariableNamingConventions">
17+
<properties>
18+
<property name="localVarPattern" value="^[a-z][a-zA-Z0-9]*$"/>
19+
</properties>
20+
</rule>
21+
22+
<!-- Replace deprecated ExcessiveMethodLength with NcssCount -->
23+
<rule ref="category/java/design.xml/NcssCount">
24+
<properties>
25+
<property name="methodReportLevel" value="25"/>
26+
<property name="classReportLevel" value="500"/>
27+
</properties>
28+
</rule>
29+
30+
<!-- Optional: Add other specific naming convention rules -->
31+
<rule ref="category/java/codestyle.xml/FieldNamingConventions"/>
32+
<rule ref="category/java/codestyle.xml/MethodNamingConventions"/>
33+
<rule ref="category/java/codestyle.xml/ClassNamingConventions"/>
34+
35+
</ruleset>

0 commit comments

Comments
 (0)