Affects PMD Version:
6.42.0+
7.0.0
Rule: ApexCRUDViolation
Description:
I'm getting the "Validate CRUD permission before SOQL/DML operation" error when updating a list of a custom object, but not on the individual.
Code Sample demonstrating the issue:
public static CustomObject__c updateCustomObject(CustomObject__c customObject) {
if (CustomObject__c.getSObjectType().getDescribe().isUpdateable() == false) {
throw new DmlException('No permissions to update.');
}
// This is fine with no PMD Error
update resultObject;
return resultObject;
}
public static List<CustomObject__c> updateCustomObjects(List<CustomObject__c> customObjects) {
if (CustomObject__c.getSObjectType().getDescribe().isUpdateable() == false) {
throw new DmlException('No permissions to update.');
}
// Getting PMD Error: Validate CRUD permission before SOQL/DML operation
update resultObjects;
return resultObjects;
}
Expected outcome:
PMD reports a violation at line ..., but that's wrong. That's a false positive.
Since I've checked the object is Updateable, shouldn't that apply to individuals and lists
Running PMD through: [CLI | Ant | Maven | Gradle | Designer | Other]
ApexPMD Extension in VSCode - chuckjonas.apex-pmd (https://marketplace.visualstudio.com/items?itemName=chuckjonas.apex-pmd)
Affects PMD Version:
6.42.0+
7.0.0
Rule: ApexCRUDViolation
Description:
I'm getting the "Validate CRUD permission before SOQL/DML operation" error when updating a list of a custom object, but not on the individual.
Code Sample demonstrating the issue:
Expected outcome:
PMD reports a violation at line ..., but that's wrong. That's a false positive.
Since I've checked the object is Updateable, shouldn't that apply to individuals and lists
Running PMD through: [CLI | Ant | Maven | Gradle | Designer | Other]
ApexPMD Extension in VSCode - chuckjonas.apex-pmd (https://marketplace.visualstudio.com/items?itemName=chuckjonas.apex-pmd)