Description: Enforce naming and formatting standards for Apex code.
Applies to: **/*.cls
Guidelines:
- Class names must be PascalCase (e.g.,
AccountService
,OpportunityHelper
) - Method names must be camelCase (e.g.,
calculateTax
,fetchOpportunities
) - Variable names must be camelCase and descriptive (e.g.,
accountList
,isClosed
) - Boolean variable names should start with
is
,has
, orcan
(e.g.,isActive
,hasAccess
) - Use plural names for collections (e.g.,
contacts
,accountMap
) - Avoid abbreviations and single-letter variables (e.g.,
acc
❌,account
✅) - Avoid SOQL or DML inside
for
loops. Use Maps and Sets to bulkify logic - DML should be in the user mode for example
insert as user
,update as user
- Use
WITH USER_MODE
explicitly for SOQL queries - Test classes must use PascalCase and end with
Test
(e.g.,AccountServiceTest
) - Test method names should describe the test scenario clearly (e.g.,
testCalculateTax_WithValidInput
) - When writing Assertions always use
Assert
class instead ofSystem.assert