PMD 配置从 5.1 迁移到 5.4

Migration of PMD configuration from 5.1 to 5.4

我在 Eclipse Kepler 中使用了 eclipse-pmd 0.9 版。现在,我将 eclipse-pmd 1.7 版与 Eclipse Mars 一起使用。

我尝试使用相同的 PMD 配置(减少到一个规则):

<?xml version="1.0"?>
<ruleset>
    <rule ref="rulesets/java/basic.xml/EmptyCatchBlock">
        <priority>1</priority>
    </rule>
</ruleset>

但我总是收到消息:

pmd.xml is not a valid PMD rule set configuration

那个规则集有什么问题?

Changelog of eclipse-pmd 说 PMD 从 5.1 变成了 5.4。

我找到了 PMD 5.1.1 的 Migration guide,但不是 PMD 5.4 的。有 PMD 5.4 的迁移指南吗?

我找到了解决方案,请参阅 changelog:

Removed Rules:

  • Basic: The following rules of ruleset "Basic" were marked as deprecated and are removed with this release now: EmptyCatchBlock, EmptyIfStatement, EmptyWhileStmt, EmptyTryBlock, EmptyFinallyBlock, EmptySwitchStatements, EmptySynchronizedBlock, EmptyStatementNotInLoop, EmptyInitializer, EmptyStatementBlock, EmptyStaticInitializer UnnecessaryConversionTemporary, UnnecessaryReturn, UnnecessaryFinalModifier, UselessOverridingMethod, UselessOperationOnImmutable, UnusedNullCheckInEquals, UselessParentheses These rules are still available in the rulesets "Empty" (rulesets/java/empty.xml) and "Unnecessary" (rulesets/java/unnecessary.xml) respectively.

从 PMD 配置中删除所有以 "Empty" 开头的规则后,我可以导入它。