Affects PMD Version:
7.6.0
Rule:
https://docs.pmd-code.org/pmd-doc-7.5.0/pmd_rules_apex_performance.html#avoidnonrestrictivequeries
Description:
When the limit is presented as the value of a constant defined in the class it is detected as a violation.
Code Sample demonstrating the issue:
public with sharing class DemoController {
public static final Integer LIMIT_ACCOUNTS = 2;
@AuraEnabled
public static List<Account> getTwoAccounts() {
List<Account> result = [
SELECT Id,
Name
FROM Account
WITH SECURITY_ENFORCED
LIMIT: LIMIT_ACCOUNTS
];
return result;
}
}
Expected outcome:
PMD reports a violation at line 5, but that's wrong. That's a false positive.
Running PMD through: [CLI | Ant | Maven | Gradle | Designer | Other]
sf scanner:run --projectdir "./force-app/" --format="csv" --outfile="CodeAnalyzerGeneral.csv" --target "./**/*.cls"
Affects PMD Version:
7.6.0
Rule:
https://docs.pmd-code.org/pmd-doc-7.5.0/pmd_rules_apex_performance.html#avoidnonrestrictivequeries
Description:
When the limit is presented as the value of a constant defined in the class it is detected as a violation.
Code Sample demonstrating the issue:
Expected outcome:
PMD reports a violation at line 5, but that's wrong. That's a false positive.
Running PMD through: [CLI | Ant | Maven | Gradle | Designer | Other]
sf scanner:run --projectdir "./force-app/" --format="csv" --outfile="CodeAnalyzerGeneral.csv" --target "./**/*.cls"