jakub holý

building the right thing, building it right, fast

Tip: How to Easily Customize PMD Rules in Eclipse

2012-08-21eclipse

The default PMD rules are little too strict for me (especially when starting on a legacy project) so I need to adjust them, usually by decreasing priority to warning. It's however quite difficult to find the rule responsible for an error message unless you know how to do it. The answer is the PMD Violations Overview view, which lists the rule names (such as "ConstructorCallsOverridableMethod", as opposed to the error message such as "Overridable method 'addSummaryPeriod' called during object construction").



Therefore:
  1. Window - Show View - Other... - PMD - Violations Overview
  2. In the top-right corner of the Violations Overview view, select e.g. only the priority 1 and 2 warnings by clicking the colored circles representing the other priorities.
  3. Expand the list down to the rule name level to find the rules you want to change
  4. Eclipse configuration: PMD - Rules Configuration - click on "Rule name" column to sort the rules by name, find the rule
Eclipse 3.7, PMD plugin 3.2.6.