forcedotcom / sfdx-code-analyzer-vscode

Salesforce Code Analyzer is a unified tool for source code analysis. Run Code Analyzer to scan multiple languages in your code and add diagnostic info to your code that describes the violations.
BSD 3-Clause "New" or "Revised" License
9 stars 1 forks source link

[BUG] Avoid operations in loop #13

Closed rubicn closed 1 year ago

rubicn commented 1 year ago

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"

jfeingold35 commented 1 year ago

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

rubicn commented 1 year ago

@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

jfeingold35 commented 1 year ago

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

rubicn commented 1 year ago

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

jfeingold35 commented 1 year ago

@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 1 year ago

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

jfeingold35 commented 1 year ago

@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 1 year ago

Scan with Code Analyzer

jfeingold35 commented 1 year ago

@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.