Added PMD extension
This commit is contained in:
parent
b333128660
commit
ba4741062c
5 changed files with 129 additions and 12 deletions
110
config/pmd.xml
Normal file
110
config/pmd.xml
Normal file
|
@ -0,0 +1,110 @@
|
|||
<?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="ConfusingTernary"/>
|
||||
<exclude name="CommentDefaultAccessModifier"/>
|
||||
<exclude name="FieldNamingConventions"/>
|
||||
<exclude name="LocalVariableCouldBeFinal"/>
|
||||
<exclude name="LocalVariableNamingConventions"/>
|
||||
<exclude name="LongVariable"/>
|
||||
<exclude name="MethodArgumentCouldBeFinal"/>
|
||||
<exclude name="OnlyOneReturn"/>
|
||||
<exclude name="PackageCase"/>
|
||||
<exclude name="ShortClassName"/>
|
||||
<exclude name="ShortMethodName"/>
|
||||
<exclude name="ShortVariable"/>
|
||||
<exclude name="UselessParentheses"/>
|
||||
<exclude name="UseUnderscoresInNumericLiterals"/>
|
||||
</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="ExcessiveClassLength"/>
|
||||
<exclude name="ExcessiveMethodLength"/>
|
||||
<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>
|
|
@ -1,6 +1,6 @@
|
|||
bld.downloadExtensionJavadoc=false
|
||||
bld.downloadExtensionSources=true
|
||||
bld.extension-jacoco=com.uwyn.rife2:bld-jacoco-report:0.9.1
|
||||
bld.extension-pmd=com.uwyn.rife2:bld-pmd:0.9.4
|
||||
bld.repositories=MAVEN_LOCAL,MAVEN_CENTRAL,RIFE2_SNAPSHOTS,RIFE2_RELEASES
|
||||
bld.downloadLocation=
|
||||
bld.sourceDirectories=
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
|
||||
package rife.bld.extension;
|
||||
|
||||
import rife.bld.BuildCommand;
|
||||
import rife.bld.Project;
|
||||
import rife.bld.publish.PublishDeveloper;
|
||||
import rife.bld.publish.PublishLicense;
|
||||
|
@ -93,4 +94,13 @@ public class DetektOperationBuild extends Project {
|
|||
public static void main(String[] args) {
|
||||
new DetektOperationBuild().start(args);
|
||||
}
|
||||
|
||||
@BuildCommand(summary = "Check source code with PMD")
|
||||
public void pmd() throws Exception {
|
||||
new PmdOperation()
|
||||
.fromProject(this)
|
||||
.addRuleSet("config/pmd.xml")
|
||||
.execute();
|
||||
}
|
||||
|
||||
}
|
|
@ -40,15 +40,15 @@ public class DetektOperation extends AbstractProcessOperation<DetektOperation> {
|
|||
private final Collection<String> input_ = new ArrayList<>();
|
||||
private final Collection<String> plugins_ = new ArrayList<>();
|
||||
private final Collection<DetektReport> report_ = new ArrayList<>();
|
||||
private boolean allRules_ = false;
|
||||
private boolean autoCorrect_ = false;
|
||||
private boolean allRules_;
|
||||
private boolean autoCorrect_;
|
||||
private String basePath_;
|
||||
private String baseline_;
|
||||
private boolean buildUponDefaultConfig_;
|
||||
private String configResource_;
|
||||
private boolean createBaseline_;
|
||||
private boolean debug_ = false;
|
||||
private boolean disableDefaultRuleSets_ = false;
|
||||
private boolean debug_;
|
||||
private boolean disableDefaultRuleSets_;
|
||||
private String excludes_;
|
||||
private boolean generateConfig_;
|
||||
private String includes_;
|
||||
|
@ -514,9 +514,7 @@ public class DetektOperation extends AbstractProcessOperation<DetektOperation> {
|
|||
}
|
||||
|
||||
/**
|
||||
* Enables parallel compilation and analysis of source files. Do some
|
||||
* benchmarks first before enabling this flag. Heuristics show performance
|
||||
* benefits starting from 2000 lines of Kotlin code.
|
||||
* Extra paths to plugin jars.
|
||||
*
|
||||
* @param jars one or more jars
|
||||
* @return this operation instance
|
||||
|
@ -527,9 +525,7 @@ public class DetektOperation extends AbstractProcessOperation<DetektOperation> {
|
|||
}
|
||||
|
||||
/**
|
||||
* Enables parallel compilation and analysis of source files. Do some
|
||||
* benchmarks first before enabling this flag. Heuristics show performance
|
||||
* benefits starting from 2000 lines of Kotlin code.
|
||||
* Extra paths to plugin jars.
|
||||
*
|
||||
* @param jars the list of jars
|
||||
* @return this operation instance
|
||||
|
|
|
@ -29,9 +29,10 @@ import java.util.logging.ConsoleHandler;
|
|||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.assertj.core.api.Assertions.*; // NOPMD
|
||||
|
||||
|
||||
@SuppressWarnings("PMD.AvoidDuplicateLiterals")
|
||||
class DetektOperationTest {
|
||||
@BeforeAll
|
||||
static void beforeAll() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue