https://pmd.github.io/ https://pmd.github.io/pmd-5.5.4/pmd-java/ https://pmd.github.io/pmd-5.5.4/usage/running.html
install
eclipse plug-inもあると思いますが、今回は、command-line用をinstall.
$ cd /home/endo/local $ wget https://downloads.sourceforge.net/project/pmd/pmd/5.5.4/pmd-bin-5.5.4.zip $ unzip pmd-bin-5.5.4.zip
run pmd
https://pmd.github.io/pmd-5.5.4/usage/running.html ↑ここにも記載がありますが、↓こんな感じで、実行&表示
$ ~/local/pmd-bin-5.5.4/bin/run.sh pmd \ -dir /home/endo/tmp/src \ -format text \ -rulesets java-basic,java-codesize /home/endo/tmp/src/HttpComm.java:39: This class has too many methods, consider refactoring it. /home/endo/tmp/src/JsonUtil.java:1: This class has a bunch of public methods and attributes /home/endo/tmp/src/JsonUtil.java:19: Avoid really long classes. /home/endo/tmp/src/JsonUtil.java:19: The class 'JsonUtil' has a Cyclomatic Complexity of 3 (Highest = 13). /home/endo/tmp/src/JsonUtil.java:19: The class 'JsonUtil' has a Modified Cyclomatic Complexity of 3 (Highest = 13). /home/endo/tmp/src/JsonUtil.java:19: The class 'JsonUtil' has a Standard Cyclomatic Complexity of 3 (Highest = 13). /home/endo/tmp/src/JsonUtil.java:23: This class has too many methods, consider refactoring it. /home/endo/tmp/src/JsonUtil.java:221: The method 'getNode' has a Cyclomatic Complexity of 11. /home/endo/tmp/src/JsonUtil.java:221: The method 'getNode' has a Modified Cyclomatic Complexity of 11. /home/endo/tmp/src/JsonUtil.java:221: The method 'getNode' has a Standard Cyclomatic Complexity of 11. : : /home/endo/tmp/src/TimeUtil.java:583: These nested if statements could be combined
※ java-basic,java-codesize 以外のrulesetは、pmd付属のjarの内容をご覧下さい