Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .coderabbit.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
reviews:
path_filters: ["**/ruleset.xml","ruleset.xml", "**/bad.java", "bad.java"]
24 changes: 24 additions & 0 deletions bad.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
public class BadExample {

private int unusedField;

public BadExample() {
// unnecessary constructor
}

public void DOStuff() {
try {
int FooBar = 1;
System.out.println("Start");

for (int i = 0; i < 30; i++) {
System.out.println("Line " + i);
}
} catch (Exception e) {
// silently ignored
} finally {
return; // forbidden in finally block
}
}
}

35 changes: 35 additions & 0 deletions ruleset.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="UTF-8"?>
<ruleset name="CodeRabbit PMD Ruleset"
xmlns="http://pmd.sourceforge.net/ruleset/2.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://pmd.sourceforge.net/ruleset/2.0.0
http://pmd.sourceforge.net/ruleset_2_0_0.xsd"
description="PMD rules aligned with CodeRabbit standards for general-purpose Java projects.">

<!-- Keep existing valid rules -->
<rule ref="category/java/bestpractices.xml/UnusedPrivateField"/>
<rule ref="category/java/errorprone.xml/EmptyCatchBlock"/>
<rule ref="category/java/errorprone.xml/ReturnFromFinallyBlock"/>
<rule ref="category/java/codestyle.xml/UnnecessaryConstructor"/>

<!-- Replace deprecated VariableNamingConventions with specific naming rules -->
<rule ref="category/java/codestyle.xml/LocalVariableNamingConventions">
<properties>
<property name="localVarPattern" value="^[a-z][a-zA-Z0-9]*$"/>
</properties>
</rule>

<!-- Replace deprecated ExcessiveMethodLength with NcssCount -->
<rule ref="category/java/design.xml/NcssCount">
<properties>
<property name="methodReportLevel" value="25"/>
<property name="classReportLevel" value="500"/>
</properties>
</rule>

<!-- Optional: Add other specific naming convention rules -->
<rule ref="category/java/codestyle.xml/FieldNamingConventions"/>
<rule ref="category/java/codestyle.xml/MethodNamingConventions"/>
<rule ref="category/java/codestyle.xml/ClassNamingConventions"/>

</ruleset>