vscode-apex-pmd
vscode-apex-pmd copied to clipboard
Update default ruleset and documentation links
Is your feature request related to a problem? Please describe.
Yes. I use default ruleset's override based on apex_ruleset as linked in readme. I noticed the plugin doesn't report Database.query(), Database.insert()
etc variants of SOQL/DML in a loop. Ruleset wasn't modified since March 2020.
If you run PMD 6.49.0 from commandline - it emits warnings.
WARNING: Discontinue using Rule name category/apex/performance.xml/AvoidSoqlInLoops as it is scheduled for removal from PMD.
PMD 7.0.0 will remove support for this Rule. (...)
AvoidSoslInLoops (...)
AvoidDmlStatementsInLoops (...)
VariableNamingConventions (...)
replacing the 3 performance rules with category/apex/performance.xml/OperationWithLimitsInLoop
correctly detects the Database.query()
Describe the solution you'd like
- update your apex_ruleset.xml. Maybe use quickstart.xml, the "ruleset.xml" in same directory is deprecated
- update readme. Current one has "PMD System Requirements" and "Apex Ruleset Reference" links pointing to 6.11. Either pin 6.49.0 or just https://pmd.github.io/latest/pmd_rules_apex.html ?
Additional context I'd like this file to count as 4 performance problems even on vanilla installation
public with sharing class PmdDemo {
public void thisWorksAsExpected() {
for(Integer i = 0; i < 10; ++i){
List<Account> accs = [SELECT Id FROM Account WITH SECURITY_ENFORCED LIMIT 10];
insert new Task();
}
}
public void makeThisWorkToo() {
for(Integer i = 0; i < 10; ++i){
List<Account> accs = Database.query('SELECT Id FROM Account WITH SECURITY_ENFORCED LIMIT 10');
Database.insert(new Task());
}
}
}