In previous article we have shown how to install and run PMD plugin in NetBeans and how to interpret the analysis report. In this tutorial we will show how to choose rules that are applicable to our project and how to define our own rules if predefined doesn’t satisfy our need.
Choosing Applicable Rules
To access PMD options, go to Tools -> Options -> Miscellaneous and choose PMD tab:
Enable Scan enables automatic project scanning in regular intervals. In the help file there is a reference for scanning interval too, but it was not present on my version of plugin.
Clicking on Manage Rules leads to the dialog that allows enabling or disabling specific rules. By clicking on < and > we’re moving selected rules to set of enabled or disabled rules. Clicking on << and >> will enable/disable all rules.
Clicking on the rule name will show short rationale and an example of the problem that rule addresses:
Clicking on Manage Rulesets allows us to import entire rulesets in either xml file or as a .jar file. For more documentation about ruleset creation, please consult PMD web site.
We have shown how to add PMD plugin to NetBeans and how to choose which rules to apply on our project. By adding PMD to our toolbox we can deliver products of higher quality, faster.