pmd 规则未包含但由 gradle 执行
pmd rule not included but executed by gradle
gradle-5.1
pmd-插件
gradle pmdMain 会产生大量 DataflowAnomalyAnalysis 类型的错误,尽管该规则被明确排除。
来自build.gradle:
plugins {
id: 'pmd'
}
pmd {
ignoreFailures = true
sourceSets = [sourceSets.main]
reportsDir = file("$project.buildDir/reports/pmd")
ruleSetFiles = files("config/pmd/ruleset.xml")
}
来自 ruleset.xml(仅规则):
< rule ref="category/java/errorprone.xml">
< exclude name="DataflowAnomalyAnalysis"/>
< /rule>
我怎样才能真正排除该规则?
Gradle PMD Plugin有两个配置规则的属性:
- 规则集文件
- 规则集
属性 ruleSets 默认启用了几个规则集(容易出错和最佳实践)。
为了仅执行 ruleSetFiles
中指定的规则,您需要将 ruleSets
明确设置为一个空列表,例如
pmd {
ignoreFailures = true
sourceSets = [sourceSets.main]
reportsDir = file("$project.buildDir/reports/pmd")
ruleSetFiles = files("config/pmd/ruleset.xml")
ruleSets = []
}
gradle-5.1 pmd-插件
gradle pmdMain 会产生大量 DataflowAnomalyAnalysis 类型的错误,尽管该规则被明确排除。
来自build.gradle:
plugins {
id: 'pmd'
}
pmd {
ignoreFailures = true
sourceSets = [sourceSets.main]
reportsDir = file("$project.buildDir/reports/pmd")
ruleSetFiles = files("config/pmd/ruleset.xml")
}
来自 ruleset.xml(仅规则):
< rule ref="category/java/errorprone.xml">
< exclude name="DataflowAnomalyAnalysis"/>
< /rule>
我怎样才能真正排除该规则?
Gradle PMD Plugin有两个配置规则的属性:
- 规则集文件
- 规则集
属性 ruleSets 默认启用了几个规则集(容易出错和最佳实践)。
为了仅执行 ruleSetFiles
中指定的规则,您需要将 ruleSets
明确设置为一个空列表,例如
pmd {
ignoreFailures = true
sourceSets = [sourceSets.main]
reportsDir = file("$project.buildDir/reports/pmd")
ruleSetFiles = files("config/pmd/ruleset.xml")
ruleSets = []
}