Skip to content

Add a new rule for Apex PMD

David Renz edited this page May 30, 2016 · 12 revisions

We will create the AvoidDmlStatementsInLoopsRule in this showcase to give you an understanding of creating new rules.

  1. Create a new java class for the rule, in our example the AvoidDmlStatementsInLoopsRule.javaclass.
  2. Try to understand similar rules, use them as starting point and implement your own rule.
  3. Add the definition of the rule to the related ruleset, in our example the category of the rule is performance, so the definition is added to the performance.xml.
  4. Add the rule to the ruleset.xml.
  5. Add the rule to the related test class, in our example the PerformanceRulesTest.java class.
  6. Create a new xml file with test cases to verify the integrity of your rule. In our example we created the AvoidDmlStatementsInLoops.xml.
  7. Run your unit tests.
Clone this wiki locally