Method name is not camelCase
ID |
apex.maintainability.naming_method |
Severity |
info |
Remediation Complexity |
trivial |
Remediation Risk |
medium |
Remediation Effort |
low |
Resource |
Naming |
Language |
Apex |
Description
Reports a method whose name does not follow the Apex convention of camelCase - a lowercase first letter and no underscores. The expected shape is ^[a-z][A-Za-z0-9]*$; adjust it if your org has settled on a different convention. Constructors are not reported.
Rationale
A method named Get_Account or GetAccount reads like a type at the call site, which is the one place the distinction matters: Utils.Process(x) gives the reader no clue whether Process is a nested class or an action. Because Apex resolves names case-insensitively, nothing but the convention keeps that distinction visible.
The following code illustrates the pattern detected by this rule:
public class NamingMethods {
public NamingMethods() {
System.debug('constructor is not reported');
}
// FLAGGED: Method name is not camelCase
public void Get_Account() {
System.debug('x');
}
// FLAGGED: Method name is not camelCase
public static Integer ComputeTotal(Integer a) {
return a;
}
public void getAccount() {
System.debug('x');
}
private static Integer calculateTotal(Integer a) {
return a;
}
}