Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update default ruleset and documentation links #112

Open
tomekduda opened this issue Sep 22, 2022 · 0 comments
Open

Update default ruleset and documentation links #112

tomekduda opened this issue Sep 22, 2022 · 0 comments

Comments

@tomekduda
Copy link

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

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());
        }
    }
}

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant