PMD - Apex Class rules

The following table shows the list of PMD Apex Class rules that are checked by Quality Clouds.

Make sure to check also the Apex Class rules.

DescriptionSeverityArea of impact
Apex unit tests should include at least one assertionHighManageability

Apex unit tests should not use @isTest(seeAllData=true)

MediumManageability
Avoid using if statements without using braces to surround the code blockMediumManageability
Avoid using "while" statements without using braces to surround the code blockMediumManageability
Avoid using if..else statements without using surrounding bracesMediumManageability
Avoid using "for" statements without using surrounding bracesMediumManageability
Avoid creating deeply nested if-then statementsMediumManageability
Methods with numerous parameters should not be usedMediumManageability
Avoid excessive class file lengthsMediumManageability
Avoid methods with excessive Lines of Code countMediumManageability
Avoid types with excessive Lines of Code countMediumManageability
Avoid constructors with excessive Lines of Code countMediumManageability
Avoid excessive cyclomatic complexityMediumManageability
Avoid classes with too many fieldsMediumScalability
Avoid classes with too many public methodsMediumManageability
Avoid SOQL inside loopsHighPerformance

Avoid DML statements inside loops

HighPerformance
Classes should explicitly declare a sharing mode if DML methods are usedHighSecurity
Redirects to user-controlled locations should be avoidedHighSecurity
Accessing endpoints over unencrypted http should be avoidedHighSecurity
Calls to addError with disabled escaping should be avoidedHighSecurity
Randomly generated IVs and keys should be used for Crypto callsHighSecurity
Avoid using DML operations in Apex class constructor/init methodHighSecurity
Avoid using untrusted / unescaped variables in DML queriesHighSecurity
Avoid System.debug and Configuration.disableTriggerCRUDSecurity()HighSecurity
Avoid hardcoded credentials used in requests to an endpointHighSecurity
Variable names should start with a Lowercase characterMediumManageability
Method names should always begin with a Lower case character, and should not contain underscoresMediumManageability
Class names should always begin with an upper case characterMediumManageability
Non-constructor methods should not have the same name as the enclosing classMediumManageability
The Global modifier should be avoidedMediumManageability
Access permissions should be checked before a SOQL/SOSL/DML operationMediumManageability
Avoid hardcoding IDsMediumManageability
Avoid empty block statementsMediumManageability
Final variables should be fully capitalized and non-final variables should not include underscoresMediumManageability
Avoid empty Catch BlockMediumManageability
Avoid Empty If StatementsMediumManageability
Avoid empty try or finally blocksMediumManageability
Avoid Sosl calls within loopsMediumManageability
Avoid empty while statementsMediumManageability
Avoid excessive standard cyclomatic complexityMediumManageability
Avoid processing unescaped URL parametersMediumManageability
Missing ApexDoc commentMediumManageability
Missing ApexDoc @descriptionMediumManageability
Avoid declaring multiple variables in a single lineLowManageability

PMD Copyright

This product includes software developed in part by support from the Defense Advanced Research Project Agency (DARPA).




Last modified on Jun 8, 2020