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"
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4