Skip to content

Commit

Permalink
Replaced List with Collection whenever applicable.
Browse files Browse the repository at this point in the history
Added rule priority configuration.

Cleaned up tests
  • Loading branch information
ethauvin committed Jun 22, 2024
1 parent 0e55b27 commit 709943e
Show file tree
Hide file tree
Showing 8 changed files with 673 additions and 168 deletions.
9 changes: 0 additions & 9 deletions .idea/runConfigurations/PmdOperation.xml

This file was deleted.

13 changes: 0 additions & 13 deletions .idea/runConfigurations/Run Tests.xml

This file was deleted.

3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# [bld](https://rife2.com/bld) Extension to Perform Static Code Analysis with [PMD](https://pmd.github.io/)


[![License](https://img.shields.io/badge/license-Apache%20License%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
[![Java](https://img.shields.io/badge/java-17%2B-blue)](https://www.oracle.com/java/technologies/javase/jdk17-archive-downloads.html)
[![bld](https://img.shields.io/badge/1.9.1-FA9052?label=bld&labelColor=2392FF)](https://rife2.com/bld)
Expand Down Expand Up @@ -33,7 +32,7 @@ public void pmdMain() throws Exception {
new PmdOperation()
.fromProject(this)
.failOnViolation(true)
.inputPaths(srcMainDirectory().toPath())
.inputPaths(srcMainDirectory())
.ruleSets("config/pmd.xml", "category/java/errorprone.xml")
.execute();
}
Expand Down
109 changes: 109 additions & 0 deletions config/pmd.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
<?xml version="1.0"?>
<ruleset name="erik"
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 https://pmd.sourceforge.io/ruleset_2_0_0.xsd">
<description>Erik's Ruleset</description>
<!-- BEST PRACTICES -->
<rule ref="category/java/bestpractices.xml">
<exclude name="AvoidPrintStackTrace"/>
<exclude name="JUnit4TestShouldUseTestAnnotation"/>
<exclude name="JUnitTestContainsTooManyAsserts"/>
<exclude name="GuardLogStatement"/>
</rule>

<rule ref="category/java/bestpractices.xml/MissingOverride">
<properties>
<property name="violationSuppressXPath"
value="//MethodDeclaration[@Name='hashCode' or @Name='equals' or @Name='toString']"/>
</properties>
</rule>


<!-- CODE STYLE -->
<rule ref="category/java/codestyle.xml">
<exclude name="AtLeastOneConstructor"/>
<exclude name="ClassNamingConventions"/>
<exclude name="CommentDefaultAccessModifier"/>
<exclude name="ConfusingTernary"/>
<exclude name="FieldNamingConventions"/>
<exclude name="LocalVariableCouldBeFinal"/>
<exclude name="LongVariable"/>
<exclude name="MethodArgumentCouldBeFinal"/>
<exclude name="OnlyOneReturn"/>
<exclude name="PackageCase"/>
<exclude name="ShortClassName"/>
<exclude name="ShortMethodName"/>
<exclude name="ShortVariable"/>
<exclude name="UseExplicitTypes"/>
<exclude name="UseUnderscoresInNumericLiterals"/>
<exclude name="UselessParentheses"/>
</rule>

<rule ref="category/java/codestyle.xml/UnnecessaryImport">
<properties>
<property name="violationSuppressRegex" value="Unused (static|.*\.\*).*"/>
</properties>
</rule>

<!-- DESIGN -->
<rule ref="category/java/design.xml">
<exclude name="AvoidCatchingGenericException"/>
<exclude name="AvoidDeeplyNestedIfStmts"/>
<exclude name="AvoidUncheckedExceptionsInSignatures"/>
<exclude name="CognitiveComplexity"/>
<exclude name="CyclomaticComplexity"/>
<exclude name="ExcessiveParameterList"/>
<exclude name="ExcessivePublicCount"/>
<exclude name="GodClass"/>
<exclude name="LawOfDemeter"/>
<exclude name="LoosePackageCoupling"/>
<exclude name="NPathComplexity"/>
<exclude name="NcssCount"/>
<exclude name="TooManyFields"/>
<exclude name="TooManyMethods"/>
<exclude name="UseObjectForClearerAPI"/>
</rule>

<!-- DOCUMENTATION -->
<rule ref="category/java/documentation.xml">
<exclude name="CommentRequired"/>
<exclude name="CommentSize"/>
</rule>

<!-- ERROR PRONE -->
<rule ref="category/java/errorprone.xml">
<exclude name="AssignmentInOperand"/>
<exclude name="AvoidCatchingNPE"/>
<exclude name="AvoidDuplicateLiterals"/>
<exclude name="AvoidFieldNameMatchingMethodName"/>
<exclude name="AvoidFieldNameMatchingTypeName"/>
<exclude name="AvoidLiteralsInIfCondition"/>
<exclude name="NullAssignment"/>
</rule>

<rule ref="category/java/errorprone.xml/AssignmentInOperand">
<properties>
<property name="allowWhile" value="true"/>
<property name="allowFor" value="true"/>
<property name="allowIf" value="true"/>
</properties>
</rule>
<rule ref="category/java/errorprone.xml/AvoidDuplicateLiterals">
<properties>
<property name="skipAnnotations" value="true"/>
</properties>
</rule>

<!-- MULTITHREADING -->
<rule ref="category/java/multithreading.xml">
</rule>

<!-- PERFORMANCE -->
<rule ref="category/java/performance.xml">
</rule>

<!-- SECURITY -->
<rule ref="category/java/security.xml">
</rule>
</ruleset>
2 changes: 1 addition & 1 deletion src/bld/java/rife/bld/extension/PmdOperationBuild.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public class PmdOperationBuild extends Project {
public PmdOperationBuild() {
pkg = "rife.bld.extension";
name = "bld-pmd";
version = version(1, 0, 1);
version = version(1, 1, 0, "SNAPSHOT");

javaRelease = 17;

Expand Down
Loading

0 comments on commit 709943e

Please sign in to comment.