PMD Apex在Windows上找不到规则资源

时间:2018-09-12 18:13:27

标签: code-analysis apex pmd static-code-analysis

我正在尝试配置PMD进行代码分析。 我使用的是VS Code,已经安装了Java 10,下载了多个版本的PMD enter image description here

我已经为VS Code安装了Apex PMD扩展并按照说明进行了配置。

但是无论选择哪个版本,都不断出现找不到资源的错误。

这是VS Code输出的一部分

  

PMD命令:java -cp“ C:\ Code \ pmd-bin-5.7.0 \ lib *” net.sourceforge.pmd.PMD -d“ c:\ Code \ Lightning \ src \ classes \ AccountController.cls “ -f csv -R” C:\ Code \ ruleset \ apex_default.xml“   错误:错误:命令失败:java -cp“ C:\ Code \ pmd-bin-5.7.0 \ lib *” net.sourceforge.pmd.PMD -d“ c:\ Code \ Lightning \ src \ classes \ AccountController。 cls“ -f csv -R” C:\ Code \ ruleset \ apex_default.xml“   2018年9月12日下午2:35:20 net.sourceforge.pmd.RulesetsFactoryUtils getRuleSets   严重:未找到规则集   net.sourceforge.pmd.RuleSetNotFoundException:找不到规则“ ExcessiveParameterList”的资源“ category / apex / design.xml”。确保资源是有效文件或URL,并且在CLASSPATH上。这是当前的类路径:C:\ Code \ pmd-bin-5.7.0 \ lib \ antlr-runtime-3.5.2.jar; C:\ Code \ pmd-bin-5.7.0 \ lib \ antlr4-runtime-4.5 .2-1.jar; C:\ Code \ pmd-bin-5.7.0 \ lib \ asm-5.0.4.jar; C:\ Code \ pmd-bin-5.7.0 \ lib \ commons-io-2.4 .jar; C:\ Code \ pmd-bin-5.7.0 \ lib \ commons-lang3-3.4.jar; C:\ Code \ pmd-bin-5.7.0 \ lib \ groovy-2.4.7.jar; C :\ Code \ pmd-bin-5.7.0 \ lib \ gson-2.5.jar; C:\ Code \ pmd-bin-5.7.0 \ lib \ javacc-5.0.jar; C:\ Code \ pmd-bin- 5.7.0 \ lib \ jaxen-1.1.6.jar; C:\ Code \ pmd-bin-5.7.0 \ lib \ jcommander-1.48.jar; C:\ Code \ pmd-bin-5.7.0 \ lib \ pmd-apex-5.7.0-apex-jorje-shaded.jar; C:\ Code \ pmd-bin-5.7.0 \ lib \ pmd-apex-5.7.0.jar; C:\ Code \ pmd-bin- 5.7.0 \ lib \ pmd-core-5.7.0.jar; C:\ Code \ pmd-bin-5.7.0 \ lib \ pmd-cpp-5.7.0.jar; C:\ Code \ pmd-bin- 5.7.0 \ lib \ pmd-cs-5.7.0.jar; C:\ Code \ pmd-bin-5.7.0 \ lib \ pmd-fortran-5.7.0.jar; C:\ Code \ pmd-bin- 5.7.0 \ lib \ pmd-go-5.7.0.jar; C:\ Code \ pmd-bin-5.7.0 \ lib \ pmd-groovy-5.7.0.jar; C:\ Code \ pmd-bin- 5.7.0 \ lib \ pmd-java-5.7.0.jar; C:\ Code \ pmd-bin-5.7.0 \ lib \ pmd-javascript-5.7.0.jar; C:\ Code \ pmd-bin- 5.7.0 \ lib \ pmd-jsp-5.7.0.jar; C:\ Co de \ pmd-bin-5.7.0 \ lib \ pmd-matlab-5.7.0.jar; C:\ Code \ pmd-bin-5.7.0 \ lib \ pmd-objectivec-5.7.0.jar; C:\代码\ pmd-bin-5.7.0 \ lib \ pmd-perl-5.7.0.jar; C:\ Code \ pmd-bin-5.7.0 \ lib \ pmd-php-5.7.0.jar; C:\代码\ pmd-bin-5.7.0 \ lib \ pmd-plsql-5.7.0.jar; C:\代码\ pmd-bin-5.7.0 \ lib \ pmd-python-5.7.0.jar; C:\代码\ pmd-bin-5.7.0 \ lib \ pmd-ruby-5.7.0.jar; C:\代码\ pmd-bin-5.7.0 \ lib \ pmd-scala-5.7.0.jar; C:\代码\ pmd-bin-5.7.0 \ lib \ pmd-swift-5.7.0.jar; C:\代码\ pmd-bin-5.7.0 \ lib \ pmd-ui-5.7.0.jar; C:\代码\ pmd-bin-5.7.0 \ lib \ pmd-visualforce-5.7.0.jar; C:\代码\ pmd-bin-5.7.0 \ lib \ pmd-vm-5.7.0.jar; C:\代码\ pmd-bin-5.7.0 \ lib \ pmd-xml-5.7.0.jar; C:\ Code \ pmd-bin-5.7.0 \ lib \ rhino-1.7.7.jar; C:\ Code \ pmd-bin-5.7.0 \ lib \ saxon-9.1.0.8-dom.jar; C:\ Code \ pmd-bin-5.7.0 \ lib \ saxon-9.1.0.8.jar; C:\ Code \ pmd- bin-5.7.0 \ lib \ scala-compiler-2.10.4.jar; C:\ Code \ pmd-bin-5.7.0 \ lib \ scala-library-2.10.4.jar; C:\ Code \ pmd- bin-5.7.0 \ lib \ scala-reflect-2.10.4.jar

如果我从命令行运行命令,则会得到类似的输出。 对于我规则集中的每个规则,都会出现此错误,这与众不同,这是扩展名附带的默认规则集。

1 个答案:

答案 0 :(得分:1)

它在PMD 6.7.0上对我有效,在5.7.0下失败:

您引用的规则“ category / apex / design.xml / ExcessiveParameterList”仅在PMD 6以后才在此路径下可用。在该版本中,我们将规则分为几类。 使用PMD 5.7.0时,您需要使用旧规则集:“ rulesets / apex / complexity.xml / ExcessiveParameterList”。 使用最新的PMD版本可能更好。有没有办法配置Apex PMD扩展?

另请参阅https://github.com/pmd/pmd/issues/1344