New PMD Rules

Updated 1 week ago by Copado Solutions

Copado now supports PMD version 6.25. As part of this upgrade, the following rules have been added to the default RuleSet:

  • ApexAssertionsShouldIncludeMessage
  • ApexUnitTestMethodShouldHaveIsTestAnnotation
  • DebugsShouldUseLoggingLevel
  • UnusedLocalVariable
  • FieldDeclarationsShouldBeAtStart
  • CognitiveComplexity
  • TestMethodsMustBeInTestClasses
  • AvoidSoslInLoops

In order to ensure these new rules are available, follow the steps below:

  1. Navigate to Setup > Object Manager > Static Code Analysis Rule.
  2. Go to Fields & Relationships and click on Rule Name.
  3. Scroll down to Values and click on New to add the new rules.
  4. Add the new rule names as picklist values (note that this name is case sensitive).
  5. Once you have added all the new picklist values, go to the Static Code Analysis Setting record and create static code analysis rules for the new values added:

  • Select the name of the rule you have added in the Rule Name field.
  • Add a priority. You can use the one defined by PMD in their documentation or define a custom priority that suits you better.
  • Enter a message.
  • Repeat this process for all the other new rules.
To save you the hassle of having to create rules manually, you can leverage the Generate Default RuleSet button. However, please be aware that if you have made any configurations to your PMD rules, these are reset when using this button.


How did we do?