You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
I have a class with several methods that each do an update on an sObject. All of these update calls are highlighted by the linter with the security-ApexCRUDViolation warning. If I fix the first of these in the file, then all the subsequent updates no longer get highlighted even though they should still be in violation.
If I fix the second in the file but not the first, all the highlights are the second are cleared but the first highlight remains. This doesn't change even if the linting is re-run.
Apex PMD Output
n/a - the linting no longer identifies the violations.
Apex PMD Settings
v0.6.2
pmdBinPath: blank
rulesets: empty
additionalClassPaths: empty
Apex File
public with sharing class CustomOpportunityUtilsController
{
private final ApexPages.StandardController controller;
private Opportunity opp;
public CustomOpportunityUtilsController(ApexPages.StandardController standardController)
{
controller = standardController;
Opportunity standardOpp = (Opportunity) controller.getRecord();
opp = [SELECT Id, StageName FROM Opportunity WHERE Id = :standardOpp.Id];
}
public PageReference moveCloseDate()
{
Date today = Date.today();
Date firstOfThisMonth = Date.newInstance(today.year(), today.month(), 1);
if (Opportunity.sObjectType.getDescribe().isUpdateable())
{
update new Opportunity(Id = opp.Id, CloseDate = firstOfThisMonth);
}
else
{
return null;
}
return new ApexPages.StandardController(opp).view();
}
public PageReference updateName()
{
update new Opportunity(Id = opp.Id, Name = 'New Opp Name');
return new ApexPages.StandardController(opp).view();
}
public PageReference closeOpps()
{
List<Opportunity> opps = [SELECT Id, StageName FROM Opportunity WHERE StageName = :opp.StageName];
for (Opportunity o : opps)
{
o.StageName = 'Closed';
}
update opps;
return new ApexPages.StandardController(opp).view();
}
}
Screenshots
After linter is run, before any fixes are implemented:
^^ All the above underlines are: Validate CRUD permission before SOQL/DML operation (rule: Security-ApexCRUDViolation)
After fixing the first update call in the file and rerunning the linter:
^^ the first query still has the violation, but now all subsequent queries/updates after the one that was fixed in moveCloseDate() are no longer highlighted despite still being in violation.
Versions (please complete the following information):
OS: Windows 11
vscode: 1.83.1
The text was updated successfully, but these errors were encountered:
Describe the bug
I have a class with several methods that each do an update on an sObject. All of these update calls are highlighted by the linter with the
security-ApexCRUDViolation
warning. If I fix the first of these in the file, then all the subsequent updates no longer get highlighted even though they should still be in violation.If I fix the second in the file but not the first, all the highlights are the second are cleared but the first highlight remains. This doesn't change even if the linting is re-run.
Apex PMD Output
n/a - the linting no longer identifies the violations.
Apex PMD Settings
v0.6.2
Apex File
Screenshots
![image](https://private-user-images.githubusercontent.com/7828988/276861831-100e9470-6335-4d1b-a1da-b1c7af8e1e70.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkzNTg3MjQsIm5iZiI6MTczOTM1ODQyNCwicGF0aCI6Ii83ODI4OTg4LzI3Njg2MTgzMS0xMDBlOTQ3MC02MzM1LTRkMWItYTFkYS1iMWM3YWY4ZTFlNzAucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI1MDIxMiUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNTAyMTJUMTEwNzA0WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9MTA3YWM2ZTY0MDY5MmNkNzI5MGY1YTg5NmI0ODZiODA4ZTljNDBhNmMxNjY2ZDBmZWE1NTdlMDFjMTNmNTYxMyZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.AMNs2P3S50cDIgPc1EWwT2IUS1F7ayreWSLsxBZGD2A)
After linter is run, before any fixes are implemented:
^^ All the above underlines are:
Validate CRUD permission before SOQL/DML operation (rule: Security-ApexCRUDViolation)
After fixing the first update call in the file and rerunning the linter:
![image](https://private-user-images.githubusercontent.com/7828988/276861746-e08fbd90-5d5e-4d6f-a66c-2d2eaa4ce04b.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkzNTg3MjQsIm5iZiI6MTczOTM1ODQyNCwicGF0aCI6Ii83ODI4OTg4LzI3Njg2MTc0Ni1lMDhmYmQ5MC01ZDVlLTRkNmYtYTY2Yy0yZDJlYWE0Y2UwNGIucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI1MDIxMiUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNTAyMTJUMTEwNzA0WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9NGRiY2EwYWIwNjc1YjQwZWFiZjUzMGIyNTI4ODlmOWFjMjE2ZWJmYjVlZDljNGMwZjRkNDEzYjRjOTI0Yzg0MiZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.msBaUfAUwyJfqM_9YbOUoTm7lVBm49I1Gkq6sCaRF4g)
^^ the first query still has the violation, but now all subsequent queries/updates after the one that was fixed in
moveCloseDate()
are no longer highlighted despite still being in violation.Versions (please complete the following information):
The text was updated successfully, but these errors were encountered: