Apex rules

ID Apex title (+ doc link) Description Severity Area of impact Affected element
1 ApexUnitTestClassShouldHaveAsserts Apex unit test classes should have at least one System.assert() or assertEquals() or AssertNotEquals() call Medium Manageability Apex class
2 ApexUnitTestShouldNotUseSeeAllDataTrue @isTest(seeAllData=true) should not be used in Apex unit tests because it opens up the existing database data for unexpected modification by tests Medium Manageability Apex class
3 IfStmtsMustUseBraces Avoid using if statements without curly braces Medium Manageability Apex class
4 WhileLoopsMustUseBraces Avoid using while statements without curly braces Medium Manageability Apex class
5 IfElseStmtsMustUseBraces Avoid using if...else statements without curly braces Medium Manageability Apex class
6 ForLoopsMustUseBraces Avoid using for statements without curly braces Medium Manageability Apex class
7 AvoidDeeplyNestedIfStmts Deeply nested if..else statements are hard to read Medium Manageability Apex class
8 ExcessiveParameterList Avoid long parameter lists Medium Manageability Apex class
9 ExcessiveClassLength Avoid really long classes (lines of code) Medium Manageability Apex class
10 NcssMethodCount
Medium Manageability Apex class
11 NcssTypeCount
Medium Manageability Apex class
12 NcssConstructorCount The constructor has an NCSS line count Medium Manageability Apex class
13 CyclomaticComplexity The method 'example()' has a cyclomatic complexity of 12 Medium Manageability Apex class
14 TooManyFields Too many fields Medium Scalability Apex class
15 ExcessivePublicCount This class has too many public methods and attributes Medium Manageability Apex class
16 AvoidSoqlInLoops Avoid Soql queries inside loops Medium Performance Trigger
17 AvoidDmlStatementsInLoops Avoid DML Statements inside loops Medium Performance Apex class
18 ApexSharingViolations Apex classes should declare a sharing model if DML or SOQL is used Medium Security Apex class
19 ApexOpenRedirect Apex classes should safely redirect to a known location Medium Security Apex class
20 ApexInsecureEndpoint Apex callouts should use encrypted communication channels Medium Security Apex class
21 ApexXSSFromEscapeFalse
Medium Security Apex class
22 ApexBadCrypto Apex Crypto should use random IV/key Medium Manageability Apex class
23 ApexCSRF Avoid making DML operations in Apex class constructor/init method Medium Security Apex class
24 ApexSOQLInjection Apex classes should escape variables merged in DML query Medium Security Apex class
25 ApexDangerousMethods Calling potentially dangerous method Medium Security Apex class
26 ApexSuggestUsingNamedCred Consider using named credentials for authenticated callouts Medium Security Apex class
27 VariableNamingConventions Variables should start with a lowercase character, 'PORTAL_ACCOUNT_ID' starts with uppercase character. High Manageability Apex class
27 VariableNamingConventions Variables should start with a lowercase character, 'Oppid' starts with uppercase character High Manageability Apex class
28 MethodNamingConventions Method names should not contain underscores, High Manageability Apex class
29 ClassNamingConventions Class names should begin with an uppercase character High Manageability Apex class
30 MethodWithSameNameAsEnclosingClass Classes should not have non-constructor methods with the same name as the class Medium Manageability Apex class
31 AvoidLogicInTrigger Avoid logic in triggers Medium Manageability Apex class
32 AvoidGlobalModifier Avoid using global modifier Medium Manageability Apex class
33 ApexCRUDViolation Validate CRUD permission before SOQL/DML operation Medium Security Apex class
34 MethodNamingConventions Method names should not start with capital letters High Manageability Apex class
35 AvoidHardcodingId Avoid hardcoding IDs Medium Manageability Apex class
36 EmptyStatementBlock Avoid empty block statements. Medium Manageability Apex class
37 VariableNamingConventions Only variables that are final should contain underscores (except for underscores in standard prefix/suffix), 'PORTAL_ACCOUNT_ID' is not final. High Manageability Apex class
38 AvoidDirectAccessTriggerMap Avoid directly accessing Trigger.old and Trigger.new Medium Manageability Apex class
39 EmptyCatchBlock Avoid empty catch blocks Medium Manageability Apex class
40 EmptyIfStmt Avoid empty if statements Medium Manageability Apex class
41 EmptyTryOrFinallyBlock Avoid empty try or finally blocks Medium Manageability Apex class
42 AvoidSoslInLoops Avoid Sosl queries inside loops Medium Manageability Apex class
43 EmptyWhileStmt Avoid empty while statements Medium Manageability Apex class
44 StdCyclomaticComplexity The class 'ApexClassStdCyclomaticComplexity' has a Standard Cyclomatic Complexity of 10 (Highest = 9). Medium Manageability Apex class
45 ApexXSSFromURLParam Apex classes should escape Strings obtained from URL parameters Medium Manageability Apex class
46 VariableNamingConventions Variables that are final and static should be all capitals High Manageability Apex class


What's in here