Skip to main content

Code reviews rule: Missing Apex documentation

Written by David Martin

Missing Apex documentation

Why is this an issue?

Apex classes, interfaces, enums, constructors, methods, and properties without documentation are harder to understand and maintain:

  • Developer productivity: Time wasted understanding undocumented code

  • Knowledge loss: Intent is lost when original developers leave

  • AI agents: Undocumented code is harder for AI tools to work with correctly

  • Onboarding: New team members struggle with undocumented codebases

This rule checks for ApexDoc comments (/** ... */) on:

  • All classes, interfaces, and enums (regardless of access modifier)

  • Public constructors, methods, and properties (private, protected, and package-private members are not flagged)

Note: Only /** ... */ ApexDoc comments satisfy this rule. Regular block comments (/* ... */) and line comments (// ...) are not treated as documentation.

Examples

Class

Example of incorrect code:

public class AccountService {
public static void processAccounts(List<Account> accounts) {
// ...
}
}

Example of correct code:

/**
* Service class for Account-related business operations.
*/
public class AccountService {
public static void processAccounts(List<Account> accounts) {
// ...
}
}

Interface

Example of incorrect code:

public interface AccountProcessor {
void process(Account acc);
}

Example of correct code:

/** Processes Account records for classification and validation. */
public interface AccountProcessor {
void process(Account acc);
}

Enum

Example of incorrect code:

public enum Priority {
HIGH, MEDIUM, LOW
}

Example of correct code:

/** Represents the priority level assigned to an Account. */
public enum Priority {
HIGH, MEDIUM, LOW
}

Constructor

Example of incorrect code:

/** Service class for Account operations. */
public class AccountService {
public AccountService() {
}
}

Example of correct code:

/** Service class for Account operations. */
public class AccountService {
/** Creates a new AccountService with default settings. */
public AccountService() {
}
}

Method

Example of incorrect code:

/** Service class for Account operations. */
public class AccountService {
public static void processAccounts(List<Account> accounts) {
// ...
}
}

Example of correct code:

/** Service class for Account operations. */
public class AccountService {
/**
* Sets priority based on industry for a list of accounts.
* @param accounts The accounts to process
*/
public static void processAccounts(List<Account> accounts) {
// ...
}
}

Property

Example of incorrect code:

/** Service class for Account operations. */
public class AccountService {
public Integer batchSize { get; set; }
}

Example of correct code:

/** Service class for Account operations. */
public class AccountService {
/** The number of records to process per batch. */
public Integer batchSize { get; set; }
}

Regular comments do not count

A /* ... */ block comment is not an ApexDoc comment. This code is still flagged:

/* This is NOT an ApexDoc comment */
public class AccountService {}

Use /** ... */ instead:

/** This IS an ApexDoc comment. */
public class AccountService {}

How can I fix violations?

  1. Add class-level documentation: Describe the class purpose and responsibilities.

  2. Document public methods: Explain what methods do, their parameters, and return values.

  3. Document public constructors and properties: Include documentation for all public-facing members, not just methods.

  4. Use /** ... */ format: Only ApexDoc comments count β€” regular block comments (/* ... */) and line comments (// ...) are not recognized by this rule.

When should I disable this rule?

You may dismiss specific violations for simple getter/setter methods or trivial code where documentation adds no value.

Resources

Did this answer your question?