简体   繁体   English

PMD找不到规则UseSingleton

[英]PMD can't find rule UseSingleton

For some weird reason PMD is giving this error: 由于一些奇怪的原因PMD给出了这个错误:

An internal error occurred during: "ReviewCode".
    Unable to find referenced rule UseSingleton; perhaps the rule name is mispelled?

this is how this rule is declared in my ruleset.xml: 这是我在ruleset.xml中声明此规则的方式:

   <rule ref="rulesets/java/design.xml/UseSingleton"/>

I'm using Eclipse Kepler with 4.0.6 PMD plugin version. 我正在使用带有4.0.6 PMD插件版本的Eclipse Kepler。 What am I doing wrong? 我究竟做错了什么?

See also the answer on the bug report #1339 and the changelog for 5.3.1 : 另请参阅错误报告#1339的答案和5.3.1更改日志

Language Java, ruleset design.xml: The rule “UseSingleton” has been renamed to “UseUtilityClass”. Language Java,ruleset design.xml:规则“UseSingleton”已重命名为“UseUtilityClass”。 See also bugs #1059 and #1339. 另见错误#1059和#1339。

This is fixed with PMD 5.3.1 and later. PMD 5.3.1及更高版本已修复此问题。

For the time being, you'll need to manually fix the ruleset file and replace UseSingleton with UseUtilityClass . 目前,您需要手动修复规则集文件并将UseSingleton替换为UseUtilityClass I'd suggest to shutdown eclipse, locate the ruleset.xml file in your workspace, change it, and start eclipse. 我建议关闭eclipse,在工作区中找到ruleset.xml文件,更改它,然后启动eclipse。

You tried to use config for PMD >= 5.0. 您尝试将配置用于PMD> = 5.0。 For lower versions you need to remove java/ from rule reference: 对于较低版本,您需要从规则引用中删除java/

<rule ref="rulesets/design.xml/UseSingleton"/>

From PMD 5.0 release notes: 从PMD 5.0发行说明:

This version of PMD breaks API compatibility with prior versions of PMD, as well as RuleSet XML compatibility. 此版本的PMD破坏了与先前版本的PMD的API兼容性,以及RuleSet XML兼容性。 Also the maven coordinates (groupId) have been changed. maven坐标(groupId)也已更改。 The decision to break compatibility, allows PMD internals and code organization to be improved to better handle additional languages. 决定打破兼容性,允许改进PMD内部和代码组织,以更好地处理其他语言。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM