development, java

pmd cli (mac)

By jere on 2018-12-04 0 Comments

这两天看了一下 PMD 要对 java 项目出一个简单的 static report.

Intellij 有 pmd 的插件,但总感觉看上去比较复杂的样子,如果要出 html report应该怎么弄呢,写下心得吧。

Install pmd

brew update && brew install pmd

Customize your own ruleset

Java 比较全的 ruleset 在这里.
创建一个自己的文件吧,把上面的 ruleset 进行剪辑(如果全用,实在是太多问题了:-( )。
注:如果不想使用其中的一个,比如 UnusedImport.

<rule ref="category/java/bestpractices.xml" >
            <exclude name="UnusedImports"/>
</rule>

Run Command

pmd pmd -d your_proj_location -R your_ruleset_file -f html | tee your_report_html

生成后就可以直接看报告了。

打赏

Leave a comment

您的电子邮箱地址不会被公开。 必填项已用*标注