modernize PMD setup
This commit is contained in:
parent
cd23d5cd85
commit
3b67aa1a60
@ -2,7 +2,7 @@ apply plugin: 'com.android.application'
|
|||||||
apply plugin: 'checkstyle'
|
apply plugin: 'checkstyle'
|
||||||
apply plugin: 'pmd'
|
apply plugin: 'pmd'
|
||||||
|
|
||||||
/* gets the version name from the latest Git tag, stripping the leading v off */
|
/* gets the version name from the latest Git tag */
|
||||||
def getVersionName = { ->
|
def getVersionName = { ->
|
||||||
def stdout = new ByteArrayOutputStream()
|
def stdout = new ByteArrayOutputStream()
|
||||||
exec {
|
exec {
|
||||||
@ -192,7 +192,7 @@ task checkstyle(type: Checkstyle) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pmd {
|
pmd {
|
||||||
toolVersion = '5.5.1'
|
toolVersion = '6.20.0'
|
||||||
consoleOutput = true
|
consoleOutput = true
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -202,7 +202,6 @@ task pmdMain(type: Pmd) {
|
|||||||
ruleSets = [] // otherwise defaults clash with the list in rules.xml
|
ruleSets = [] // otherwise defaults clash with the list in rules.xml
|
||||||
source 'src/main/java'
|
source 'src/main/java'
|
||||||
include '**/*.java'
|
include '**/*.java'
|
||||||
exclude '**/kellinwood/**/*.java'
|
|
||||||
}
|
}
|
||||||
|
|
||||||
task pmdTest(type: Pmd) {
|
task pmdTest(type: Pmd) {
|
||||||
|
@ -4,6 +4,10 @@
|
|||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0 http://pmd.sf.net/ruleset_xml_schema.xsd"
|
xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0 http://pmd.sf.net/ruleset_xml_schema.xsd"
|
||||||
xsi:noNamespaceSchemaLocation="http://pmd.sf.net/ruleset_xml_schema.xsd">
|
xsi:noNamespaceSchemaLocation="http://pmd.sf.net/ruleset_xml_schema.xsd">
|
||||||
|
<description>
|
||||||
|
Rules for the project code aka "main".
|
||||||
|
</description>
|
||||||
|
|
||||||
|
<!-- TODO <rule ref="category/java/errorprone.xml/CloseResource"/> -->
|
||||||
|
|
||||||
<rule ref="rulesets/java/imports.xml" />
|
|
||||||
</ruleset>
|
</ruleset>
|
||||||
|
@ -4,8 +4,14 @@
|
|||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0 http://pmd.sf.net/ruleset_xml_schema.xsd"
|
xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0 http://pmd.sf.net/ruleset_xml_schema.xsd"
|
||||||
xsi:noNamespaceSchemaLocation="http://pmd.sf.net/ruleset_xml_schema.xsd">
|
xsi:noNamespaceSchemaLocation="http://pmd.sf.net/ruleset_xml_schema.xsd">
|
||||||
|
<description>
|
||||||
|
Rules for the test harness code aka "androidTest" and "test".
|
||||||
|
</description>
|
||||||
|
|
||||||
|
<!-- ideally these would be promoted to rules.xml -->
|
||||||
|
<rule ref="category/java/bestpractices.xml/ConstantsInInterface"/>
|
||||||
|
<rule ref="category/java/bestpractices.xml/UseCollectionIsEmpty"/>
|
||||||
|
<rule ref="category/java/errorprone.xml/AvoidFieldNameMatchingMethodName"/>
|
||||||
|
<rule ref="category/java/errorprone.xml/AvoidFieldNameMatchingTypeName"/>
|
||||||
|
|
||||||
<rule ref="rulesets/java/imports.xml">
|
|
||||||
<exclude name="TooManyStaticImports" /><!-- Static imports are commonly used for JUnit tests -->
|
|
||||||
</rule>
|
|
||||||
</ruleset>
|
</ruleset>
|
||||||
|
@ -4,49 +4,49 @@
|
|||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0 http://pmd.sf.net/ruleset_xml_schema.xsd"
|
xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0 http://pmd.sf.net/ruleset_xml_schema.xsd"
|
||||||
xsi:noNamespaceSchemaLocation="http://pmd.sf.net/ruleset_xml_schema.xsd">
|
xsi:noNamespaceSchemaLocation="http://pmd.sf.net/ruleset_xml_schema.xsd">
|
||||||
|
<description>
|
||||||
|
Rules for the whole project
|
||||||
|
</description>
|
||||||
|
|
||||||
<rule ref="rulesets/java/basic.xml">
|
<rule ref="category/java/bestpractices.xml/AbstractClassWithoutAbstractMethod"/>
|
||||||
<exclude name="CollapsibleIfStatements"/> <!--sometimes forces hard to read code-->
|
<rule ref="category/java/bestpractices.xml/AvoidReassigningLoopVariables"/>
|
||||||
</rule>
|
<rule ref="category/java/bestpractices.xml/DefaultLabelNotLastInSwitchStmt"/>
|
||||||
<rule ref="rulesets/java/unusedcode.xml"/>
|
<rule ref="category/java/bestpractices.xml/MissingOverride"/>
|
||||||
<rule ref="rulesets/java/android.xml"/>
|
<rule ref="category/java/bestpractices.xml/UnusedFormalParameter"/>
|
||||||
<rule ref="rulesets/java/clone.xml"/>
|
<rule ref="category/java/bestpractices.xml/UnusedLocalVariable"/>
|
||||||
<rule ref="rulesets/java/finalizers.xml"/>
|
<rule ref="category/java/bestpractices.xml/UnusedPrivateField"/>
|
||||||
<rule ref="rulesets/java/migrating.xml"/>
|
<rule ref="category/java/bestpractices.xml/UnusedPrivateMethod"/>
|
||||||
<rule ref="rulesets/java/unnecessary.xml">
|
<rule ref="category/java/codestyle.xml/UnnecessaryConstructor"/>
|
||||||
<exclude name="UselessParentheses"/> <!--Too nitpicky-->
|
<rule ref="category/java/codestyle.xml/UnnecessaryLocalBeforeReturn"/>
|
||||||
</rule>
|
<rule ref="category/java/design.xml/AvoidRethrowingException"/>
|
||||||
<rule ref="rulesets/java/empty.xml">
|
<rule ref="category/java/design.xml/AvoidThrowingNewInstanceOfSameException"/>
|
||||||
<exclude name="EmptyCatchBlock"/> <!--Ignoring an exception-->
|
<rule ref="category/java/design.xml/AvoidThrowingNullPointerException"/>
|
||||||
<exclude name="EmptyWhileStmt"/> <!--Can be useful sometimes-->
|
<rule ref="category/java/design.xml/DoNotExtendJavaLangError"/>
|
||||||
</rule>
|
<rule ref="category/java/design.xml/FinalFieldCouldBeStatic"/>
|
||||||
<rule ref="rulesets/java/optimizations.xml/PrematureDeclaration"/>
|
<rule ref="category/java/design.xml/ImmutableField"/>
|
||||||
<rule ref="rulesets/java/optimizations.xml/AddEmptyString"/>
|
<rule ref="category/java/design.xml/LogicInversion"/>
|
||||||
<rule ref="rulesets/java/optimizations.xml/UseArraysAsList"/>
|
<rule ref="category/java/design.xml/SimplifyBooleanExpressions"/>
|
||||||
<rule ref="rulesets/java/optimizations.xml/UnnecessaryWrapperObjectCreation"/>
|
<rule ref="category/java/design.xml/SimplifyBooleanReturns"/>
|
||||||
|
<rule ref="category/java/design.xml/SingularField"/>
|
||||||
<rule ref="rulesets/java/controversial.xml/UnnecessaryConstructor"/>
|
<rule ref="category/java/errorprone.xml/AssignmentInOperand"/>
|
||||||
<rule ref="rulesets/java/controversial.xml/UnnecessaryParentheses"/>
|
<rule ref="category/java/errorprone.xml/AvoidAssertAsIdentifier"/>
|
||||||
|
<rule ref="category/java/errorprone.xml/AvoidBranchingStatementAsLastInLoop"/>
|
||||||
<rule ref="rulesets/java/strictexception.xml/AvoidRethrowingException"/>
|
<rule ref="category/java/errorprone.xml/AvoidCallingFinalize"/>
|
||||||
<rule ref="rulesets/java/strictexception.xml/AvoidCatchingThrowable"/>
|
<rule ref="category/java/errorprone.xml/AvoidCatchingNPE"/>
|
||||||
<rule ref="rulesets/java/strictexception.xml/AvoidCatchingNPE"/>
|
<rule ref="category/java/errorprone.xml/AvoidCatchingThrowable"/>
|
||||||
<rule ref="rulesets/java/strictexception.xml/DoNotExtendJavaLangError"/>
|
<rule ref="category/java/errorprone.xml/AvoidMultipleUnaryOperators"/>
|
||||||
<rule ref="rulesets/java/strictexception.xml/DoNotThrowExceptionInFinally"/>
|
<rule ref="category/java/errorprone.xml/AvoidUsingOctalValues"/>
|
||||||
<rule ref="rulesets/java/strictexception.xml/AvoidThrowingNewInstanceOfSameException"/>
|
<rule ref="category/java/errorprone.xml/BrokenNullCheck"/>
|
||||||
<rule ref="rulesets/java/strictexception.xml/AvoidThrowingNullPointerException"/>
|
<rule ref="category/java/errorprone.xml/CallSuperFirst"/>
|
||||||
|
<rule ref="category/java/errorprone.xml/CallSuperLast"/>
|
||||||
<rule ref="rulesets/java/design.xml/FinalFieldCouldBeStatic"/>
|
<rule ref="category/java/errorprone.xml/DoNotHardCodeSDCard" />
|
||||||
<rule ref="rulesets/java/design.xml/CloseResource"/>
|
<rule ref="category/java/errorprone.xml/DoNotThrowExceptionInFinally"/>
|
||||||
<rule ref="rulesets/java/design.xml/DefaultLabelNotLastInSwitchStmt"/>
|
<rule ref="category/java/errorprone.xml/EqualsNull"/>
|
||||||
<rule ref="rulesets/java/design.xml/UnnecessaryLocalBeforeReturn"/>
|
<rule ref="category/java/errorprone.xml/IdempotentOperations"/>
|
||||||
<rule ref="rulesets/java/design.xml/NonCaseLabelInSwitchStatement"/>
|
<rule ref="category/java/errorprone.xml/NonCaseLabelInSwitchStatement"/>
|
||||||
<rule ref="rulesets/java/design.xml/EqualsNull"/>
|
<rule ref="category/java/performance.xml/AddEmptyString"/>
|
||||||
<rule ref="rulesets/java/design.xml/IdempotentOperations"/>
|
<rule ref="category/java/performance.xml/UnnecessaryWrapperObjectCreation"/>
|
||||||
<rule ref="rulesets/java/design.xml/ImmutableField"/>
|
<rule ref="category/java/performance.xml/UseArraysAsList"/>
|
||||||
<rule ref="rulesets/java/design.xml/SingularField"/>
|
<rule ref="category/java/security.xml"/>
|
||||||
<rule ref="rulesets/java/design.xml/SimplifyBooleanReturns"/>
|
|
||||||
<rule ref="rulesets/java/design.xml/SimplifyBooleanExpressions"/>
|
|
||||||
<rule ref="rulesets/java/design.xml/LogicInversion"/>
|
|
||||||
|
|
||||||
</ruleset>
|
</ruleset>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user