Skip to content

Add a new rule for Apex PMD

David Renz edited this page Jun 7, 2016 · 12 revisions

TODO: Tell people about the structure of the PMD Maven modules. 1 Core and one per language. What they have to care about and what not. Which errors they can ignore. I would expect a small comment for EACH screenshot of the kind: "Cool, now we got this. Only one step left.

  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.
  3. Implement your own rule.
  4. 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.
  5. Add the rule to the ruleset.xml.
  6. Add the rule to the related test class, in our example the PerformanceRulesTest.java class.
  7. Create a new xml file with test cases to verify the integrity of your rule. In our example we created the AvoidDmlStatementsInLoops.xml.
  8. Run the unit tests of the test class you updated in step 5.
  9. If all tests run successfully you are done.
Clone this wiki locally