从maven插件中的PMD中删除单个规则检查 [英] Remove a single rule check from PMD in maven plugin
问题描述
我想在POM中排除单个PMD规则,但它不起作用。
我尝试创建一个pmd-exclude.xml(与pom.xml在同一个目录中):
I want to exclude a single PMD rule in POM, but it is not working. I have tried creating a pmd-exclude.xml (in the same dir as the pom.xml):
<?xml version="1.0"?>
<ruleset name="remove_rules">
<description>Remove rules</description>
<rule ref="rulesets/unnecessary.xml">
<exclude name="UselessParentheses"/>
</rule>
</ruleset>
来自 http://www.ing.iac.es/~docs/external/java/pmd/howtomakearuleset.html 并在pom中引用它。 xml:
From http://www.ing.iac.es/~docs/external/java/pmd/howtomakearuleset.html and referenced it in pom.xml:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
<version>3.0.1</version>
<configuration>
<sourceEncoding>utf-8</sourceEncoding>
<rulesets>
<ruleset>${pom.basedir}/pmd-exclude.xml</ruleset>
</rulesets>
</configuration>
</plugin>
但它会不断报告这些规则。
But it keeps reporting these rules.
另外:我不想指定它必须检查哪些规则,因为较新版本可以(并且将)包含新规则,我不想检查每个新版本中将运行哪些新规则。
Also: I do not want to specify which rules it must check, as newer versions can (and will) include new ones and I do not want to check which new rules will run in every new version.
推荐答案
我认为您需要添加要检查的规则集,并且只丢弃您不需要的特定规则。
I think you will need to add the rulesets you want to check and discard just the specific rule you don't need.
pmd-exclude.xml应如下所示:
The pmd-exclude.xml should look like this:
<?xml version="1.0" encoding="UTF-8"?>
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
name="Android Application Rules"
xmlns="http://pmd.sf.net/ruleset/1.0.0"
xsi:noNamespaceSchemaLocation="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" >
<description>Remove rules</description>
<rule ref="rulesets/clone.xml" />
<rule ref="rulesets/finalizers.xml" />
<rule ref="rulesets/imports.xml" />
<rule ref="rulesets/logging-java.xml" />
<rule ref="rulesets/unnecessary.xml" >
<exclude name="UselessParentheses" />
</rule>
</ruleset>
这篇关于从maven插件中的PMD中删除单个规则检查的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!