[3.4.0-map-sdk] add pmd rule set
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||
apply from: "config.gradle"
|
||||
apply from: "javadoc.gradle"
|
||||
|
||||
buildscript {
|
||||
apply from: rootProject.file('gradle/ext.gradle')
|
||||
repositories {
|
||||
@@ -50,6 +51,7 @@ buildscript {
|
||||
}
|
||||
|
||||
allprojects {
|
||||
apply from: rootProject.file('codequality/pmd.gradle')
|
||||
repositories {
|
||||
mavenLocal()
|
||||
maven { url 'http://nexus.zhidaoauto.com/repository/maven-releases/' }
|
||||
@@ -70,7 +72,6 @@ allprojects {
|
||||
}
|
||||
google()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
task clean(type: Delete) {
|
||||
|
||||
41
codequality/custom-pmd-ruleset.xml
Normal file
41
codequality/custom-pmd-ruleset.xml
Normal file
@@ -0,0 +1,41 @@
|
||||
<?xml version="1.0"?>
|
||||
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="Custom ruleset"
|
||||
xmlns="http://pmd.sourceforge.net/ruleset/2.0.0"
|
||||
xsi:noNamespaceSchemaLocation="http://pmd.sf.net/ruleset_xml_schema.xsd"
|
||||
xsi:schemaLocation="http://pmd.sourceforge.net/ruleset/2.0.0 http://pmd.sourceforge.net/ruleset_2_0_0.xsd">
|
||||
<description>
|
||||
This ruleset checks my code for bad stuff
|
||||
</description>
|
||||
|
||||
<!--https://pmd.github.io/pmd-5.6.1/pmd-java/index.html-->
|
||||
|
||||
<exclude-pattern>.*/R.java</exclude-pattern>
|
||||
<exclude-pattern>.*/gen/.*</exclude-pattern>
|
||||
<exclude-pattern>.*Dagger*.*</exclude-pattern>
|
||||
|
||||
<!-- 容易出现运行时错误 -->
|
||||
<rule ref="category/java/errorprone.xml/AvoidBranchingStatementAsLastInLoop" />
|
||||
<rule ref="category/java/errorprone.xml/AvoidDecimalLiteralsInBigDecimalConstructor" />
|
||||
<rule ref="category/java/errorprone.xml/AvoidMultipleUnaryOperators" />
|
||||
<rule ref="category/java/errorprone.xml/AvoidUsingOctalValues" />
|
||||
<rule ref="category/java/errorprone.xml/BrokenNullCheck" />
|
||||
<rule ref="category/java/errorprone.xml/CheckSkipResult" />
|
||||
<rule ref="category/java/errorprone.xml/ClassCastExceptionWithToArray" />
|
||||
<rule ref="category/java/errorprone.xml/DontUseFloatTypeForLoopIndices" />
|
||||
<rule ref="category/java/errorprone.xml/JumbledIncrementer" />
|
||||
<rule ref="category/java/errorprone.xml/MisplacedNullCheck" />
|
||||
<rule ref="category/java/errorprone.xml/OverrideBothEqualsAndHashcode" />
|
||||
<rule ref="category/java/errorprone.xml/ReturnFromFinallyBlock" />
|
||||
<rule ref="category/java/errorprone.xml/UnconditionalIfStatement" />
|
||||
<rule ref="category/java/errorprone.xml/UnnecessaryConversionTemporary" />
|
||||
<rule ref="category/java/errorprone.xml/UnusedNullCheckInEquals" />
|
||||
<rule ref="category/java/errorprone.xml/UselessOperationOnImmutable" />
|
||||
<!-- 多线程时问题-->
|
||||
<rule ref="category/java/multithreading.xml/AvoidThreadGroup" />
|
||||
<rule ref="category/java/multithreading.xml/DontCallThreadRun" />
|
||||
<rule ref="category/java/multithreading.xml/DoubleCheckedLocking" />
|
||||
<!-- 需要优化代码的地方-->
|
||||
<rule ref="category/java/performance.xml/BigIntegerInstantiation" />
|
||||
<!-- 安全问题-->
|
||||
<rule ref="category/java/security.xml" />
|
||||
</ruleset>
|
||||
@@ -1 +1,25 @@
|
||||
//apply plugin:"pmd"
|
||||
apply plugin: "pmd"
|
||||
|
||||
def pmdConfigPath = rootProject.file("codequality").path
|
||||
|
||||
task pmd(type:Pmd){
|
||||
//忽略失败,如果设置为true,检测出bug会停止task
|
||||
ignoreFailures = false
|
||||
consoleOutput = true
|
||||
//filter路径
|
||||
ruleSetFiles = files("${pmdConfigPath}/custom-pmd-ruleset.xml") // todo 新增rules
|
||||
ruleSets = []
|
||||
//检测资源路径
|
||||
source 'src/main/java','src/jinlvvan/java','src/driverm1/java'
|
||||
//排除项
|
||||
exclude '**/gen/**'
|
||||
|
||||
reports {
|
||||
xml.getRequired().set(false)
|
||||
html.getRequired().set(true)
|
||||
//结果输出到项目根目录下的 build/reports/pmd 文件夹中,只需要html格式的结果文档
|
||||
def destination = new File(new File("${project.rootProject.buildDir.path}/reports/pmd"), "${project.name}-pmd.html")
|
||||
html.destination(destination)
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user