Pmd is a tool for running code static analysis for multiple languages. The first thing you need to use it is download it from Pmd’s website. Clicking the download button will download a zip file. Uncompress that zip and you will have all you need.

Running code static analysis

Once you have pmd on your computer you can analyse your code using this command:

<path to pmd>/bin/ pmd -d <src folder> -l java -f <reporting format> -R <rules>

Reporting format can be one or more(separated by commas) of these: csv, html, text, textcolor, xml.

Rules can be found in the Pmd rulesets index, but you can find the correct way to call it in your /docs/rules/rules/java folder. For example, there is a file called finalizers there, so you can use a rule called java-finalizers.

Here is how I use it:

<path to pmd>/bin/ pmd -d src/ -l java -f text -R java-android,java-basic,java-braces,java-clone,java-codesize,java-comments,java-controversial,java-design,java-empty,java-finalizers,java-imports,java-j2ee,java-junit,java-naming,java-optimizations,java-strictexception,java-strings,java-sunsecure,java-typeresolution,java-unnecessary,java-unusedcode

Copy paste detector

Pmd also comes with a copy paste detector that can help you prevent duplication of code. You can use it like this:

<path to pmd>/bin/ cpd --minimum-tokens 50 --files src/ --language java

Minimum tokens is the number of lines that need to be repeated for Pmd to give you a warning.

[ android  automation  java  productivity  ]
Monitoring Kubernetes Resources with Fabric8 Informers
Managing Kubernetes Objects With Yaml Configurations
Introduction to Bazel
Monetizing a Jekyll blog with Adsense
Introduction to Simple Workflow Service (SWF)