A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/pmd/pmd/issues/3201 below:

[apex] ApexCRUDViolation doesn't report Database class DMLs, inline no-arg object instantiations and inline list initialization · Issue #3201 · pmd/pmd · GitHub

Affects PMD Version:
5.5.3 - 6.36.0

Rule:

ApexCRUDViolation

Description:

When using the Database class, inline list initialization or no-arg object initialization in the same statement as a DML call the ApexCRUDViolation rule fails to report it

Code Sample demonstrating the issue:

/**
 * @description X
 */
public with sharing class CRUDCheck {
    
    /**
     * @description X
     */
    public static void checkMe() {

        Account acc = new Account(Name = 'X');

        //these gets reported
        insert acc; 
        insert new Account(Name = 'X');
        

        // these doesn't get reported
        insert new Account();
        insert new Account[]{new Account()};
        insert new Account[]{new Account(Name = 'X')};
        Database.insert(acc);
        Database.insert(new Account());
        Database.insert(new Account(Name = 'X'));
    }
}

Expected outcome:

Running PMD through: [CLI | Ant | Maven | Gradle | Designer | Other]

Apex PMD VSCode Extension


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