forcedotcom/sfdx-code-analyzer-vscode

[BUG] Avoid operations in loop

Closed this issue · 9 comments

rubicn commented

Describe the bug
For loop with inner class SOQL not showing "Avoid operations in loops"

To Reproduce
Create 2 classes with 2 methods for each one of them
one with a for loop that calling the other class method.
The other class method should return a SOQL List.
image
image

Expected behavior
should get a warning "Avoid operations in loops that may hit governor limits"

@rubicn , which command are you running, and do you have a code snippet that can reproduce?

rubicn commented

@rubicn , which command are you running, and do you have a code snippet that can reproduce?

command: sf scanner:run -t "force-app\main\default\classes\Test1.cls,force-app\main\default\classes\Test2.cls" -c "Security,Design,Best Practices,Performance,Code Style,Error Prone" --format csv > code_review.csv

image

image

@rubicn , I'm confused. Are you running this through the VSCode Extension's right-click commands, or via the CLI directly?

rubicn commented

this is the same, isn't it?
also for VSCode Extension right-click commands this is not given me a feedback for this issue

@rubicn , the two VSCode command correspond to different CLI commands.
The "...with Code Analyzer" one is equivalent to doing sfdx scanner:run, while the "...with Graph-Engine path-based analysis" is equivalent to sfdx scanner:run:dfa.
So if you're using the extension, then it matters which right-click command you're using.
And if you're not using the extension but are instead running directly through the CLI, it would be best if you could create the issue on the repo for the scanner itself instead of here, in order to keep paper trails clean

rubicn commented

I'm using the extension, right-click the command still it doesn't hit the "Avoid operations in loops" in that case.

@rubicn , I still need to know which right-click command you're using. The "Scan with Code Analyzer" one or the "Scan with Graph-Engine path-based analysis" one?

rubicn commented

Scan with Code Analyzer

@rubicn , thanks for clarifying, and thanks for logging this on the Scanner repo as #1182. Please see my response on that Issue for an explanation of why this is working as expected.