PMD is a code analyzer that permits us to easily find errors in our code. Here we will see how to use it directly in Eclipse with a plugin.
Installation
We go to Help / Install New Software. In Work we add https://dl.bintray.com/pmd/pmd-eclipse-plugin/updates/ and press Enter. We mark PMD 4 for Eclipse and click on Next > (it will take some time). We advance to the end of the installation and restart Eclipse.
Configuration
We go to Window / Preferences / PMD. There we can configure the analyzer.
Use
On the project’s name, right click and click on PMD / Check Code.
Revision of the results
If we didn’t modify the default configuration, a new perspective called “PMD” will be open, where all the errors and their explanation will be shown.
Repository
A small example project to test PMD is located at https://github.com/luisgomezcaballero/pmd-demo.
So, what do you think ?