Undocumented Apex methods
Why is this an issue?
Methods without documentation comments make code harder to understand and maintain. When developers encounter an undocumented method, they must read through the implementation to understand:
What the method does
What parameters it expects and their constraints
What value it returns
What exceptions it might throw
Well-documented methods improve team productivity, reduce onboarding time for new developers, and make code reviews more effective.
Examples
Example of incorrect code:
public class AccountService {
public static List<Account> getActiveAccounts(String industry, Integer limit) {
return [SELECT Id, Name FROM Account
WHERE Industry = :industry AND IsActive__c = true
LIMIT :limit];
}
}
Example of correct code:
public class AccountService {
/**
* Retrieves active accounts filtered by industry.
* @param industry The industry to filter by (e.g., 'Technology', 'Healthcare')
* @param recordLimit Maximum number of accounts to return
* @return List of active Account records matching the criteria
*/
public static List<Account> getActiveAccounts(String industry, Integer recordLimit) {
return [SELECT Id, Name FROM Account
WHERE Industry = :industry AND IsActive__c = true
LIMIT :recordLimit];
}
}
How can I fix violations?
This rule supports autofix.
Add a comment before the method. The rule is satisfied by any comment style, including single-line (//), block (/* */), or ApexDoc (/** */) comments.
When should I disable this rule?
You may dismiss specific violations for:
Simple getter and setter methods where the purpose is obvious from the method name.
Private helper methods in test classes.
Overridden methods where documentation exists in the parent class or interface.
Resources
