@AuraEnabled member is not public or global
ID |
apex.correctness.auraenabled_visibility |
Severity |
high |
Remediation Complexity |
trivial |
Remediation Risk |
low |
Remediation Effort |
low |
Resource |
Api Design |
Language |
Apex |
Rationale
The Lightning framework calls the member from outside the class, so anything narrower than public cannot be reached. The annotation makes the code look wired up, the component compiles, and the failure only appears at runtime as an empty result or an error in the browser - typically in a sandbox demo rather than in the pipeline, because no Apex test exercises the component’s call path.
The following code illustrates the pattern detected by this rule:
public with sharing class AccountController {
// FLAGGED: @AuraEnabled member is not public or global
@AuraEnabled
private static List<Account> loadAccounts() {
return [SELECT Id, Name FROM Account];
}
// FLAGGED: @AuraEnabled member is not public or global
@AuraEnabled(cacheable=true)
private static Integer countAccounts() {
return 0;
}
@AuraEnabled
public static List<Account> loadAccountsPublic() {
return [SELECT Id, Name FROM Account];
}
@AuraEnabled(cacheable=true)
public static Integer countAccountsPublic() {
return 0;
}
}