New PMD Rules
Copado now supports PMD version 6.30. As part of this upgrade, a new rule has been added to the default RuleSet while others have been deprecated:
- New rule: OperationWithLimitsInLoop.
- Deprecated rules: AvoidDmlStatementsInLoops, AvoidSoqlInLoops and AvoidSoslInLoops.
In order to ensure the rules are updated, follow the steps below.
To add the new rule:
- Navigate to Setup > Object Manager > Static Code Analysis Rule.
- Go to Fields & Relationships and click on Rule Name.
- Scroll down to Values and click on New to add the new rule.
- Add the new rule name as a picklist value (note that this name is case sensitive).
- Once you have added the new picklist value, go to the Static Code Analysis Setting record and create static code analysis rules for the new value added:
- Go to the Static Code Analysis Settings record.
- Navigate to the Static Code Analysis Rules related list and click on New to create a new rule:
- 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.
- Click on Save.
To delete the deprecated rules:
- Navigate to the Static Code Analysis Settings record.
- Go to the Static Code Analysis Rules related list.
- Click on the drop-down menu next to each of the relevant rules to delete them.