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
7 stars 1 forks source link

[BUG]Unexpected end of JSON input #102

Open LilianaRTSf opened 2 months ago

LilianaRTSf commented 2 months ago

Hi, I am getting a JSON error every time i run the code analyzer in VS code: " Unexpected end of JSON input", in all my salesforce projects

image

jfeingold35 commented 1 month ago

@LilianaRTSf , which command are you using, and what's the code you're running it against?

jfeingold35 commented 1 month ago

@LilianaRTSf , also, do you have a valid sfdx-project.json file in the root of your project?

LilianaRTSf commented 1 month ago

Hello, I am using the sfdx menu, I select a class and click "SFDX: Scan selected files or folders with code analyzer" I also tried the "SFDX:Scan current file with code analyzer", I have a sfdx-project.json, I can connect to my org and retrieve-deploy

jfeingold35 commented 1 month ago

@LilianaRTSf , can you post the file that you're trying to scan? We're struggling to reproduce this on our end. Also, can you please indicate the following:

LilianaRTSf commented 1 month ago

I am using v4.2.0, MacOs Sonoma 14.5

jfeingold35 commented 1 month ago

@LilianaRTSf , could you also please post the file you're trying to scan? We can't reproduce it locally, so it's possible it's something to do with your file.

stephen-carter-at-sf commented 1 month ago

@LilianaRTSf With VS Code open, can you please click on Help > "Toggle Developer Tools" which should reveal what looks like a chrome developer console window.

Then please do your repro steps and see what error messages appear in the console. Then paste those full error messages here please.

Additionally, have you tried to reproduce the issue with our CLI, specifically the sf scanner run command?

LilianaRTSf commented 1 month ago

Hi, thank you all for your help, yesterday someone from my work helped me and I installed code analyzer via command line, also installed node and npm, to install a missing file called RetireJS, which was causing the error. Running Code Analyzer with the command line works fine (sf scanner run --normalize-severity --target force-app/main/default/classes/class.cls --outfile results2.html), but when I use the menu "SFDX: Scan selected files or folders with code analyzer" i get the error "[error] RetireJS: env: node: No such file or directory" but i already installed it image

jfeingold35 commented 1 month ago

@LilianaRTSf , stupid question, but did you restart VSCode after you installed all of these things?

stephen-carter-at-sf commented 2 weeks ago

@LilianaRTSf We are unable to reproduce on our end. Is this still an issue with you after installing the latest CLI and VS Code Extension?