Unable to finish SonarLint Analysis in VSCode

vscode

(Evan Greensmith) #1

I installed SonarLint and added some lines to a typescript file to attempt to see some sonar lint annotations. I tried adding the following lines to a method:
const password = ‘abcde’;
alert(‘hello’);
No annotations were added. Any help or pointers on where to get more details would be helpful

In the SonarLint output it seems to get to (see full output below)
[Info - 17:57:23] Started SonarTS Analysis
but there is no following Finished SonarTS Analysis

I attempted to explicitly set a javaHome in my user settings:
{
“gitlens.advanced.messages”: {
“suppressShowKeyBindingsNotice”: true
},
“gitlens.keymap”: “alternate”,
“typescript.updateImportsOnFileMove.enabled”: “always”,
“sonarlint.ls.javaHome”: “C:\Program Files\Java\jdk1.8.0_131”
}

SonarLint version: 1.4.0
I am also separately using SonarLint for Eclipse (but whether or not eclipse is running makes no difference)

Other Extentions:
danwahlin.angular2-snippets (1.0.19)
GitLens (8.5.4)
TSLint (1.0.34)


  • Full Output

Starting standalone SonarLint engine…

Using 4 analyzers

Create : C:\Users\evan.sonarlint\plugins

Plugin cache: C:\Users\evan.sonarlint\plugins

Create : C:\Users\evan.sonarlint\plugins_tmp

Load plugins

Load plugins (done) | time=18ms

Plugins:

  • SonarPHP 2.13.0.3107 (php)

  • SonarPython 1.10.0.2131 (python)

  • SonarTS 1.7.0.2893 (typescript)

  • SonarJS 4.1.0.6085 (javascript)

[Info - 17:57:16] Starting SonarTS Server

Deploying bundle to C:\Users\evan.sonarlint\work.sonartmp_6828073269640753934\3037009898678434746

[Info - 17:57:23] Using typescript at [C:\Users\evan\node_modules\typescript], version 2.3.4

[Info - 17:57:23] SonarTS Server is started

[Info - 17:57:23] SonarTS Server connected to 58741

Standalone SonarLint engine started

Analysis triggered on file:///.component.ts with configuration:

[

baseDir: c:<redacted>

workDir: c:<redacted>.sonarlint

extraProperties: {}

excludedRules: []

includedRules: []

inputFiles: [

c:<redacted>.component.ts (UTF-8) [ts]

]

]

Available languages:

  • PHP => “php”

  • Python => “py”

  • TypeScript => “ts”

  • JavaScript => “js”

Start analysis

Declared extensions of language PHP were converted to php: /*.php,/.php3,**/.php4,/*.php5,/.phtml,**/.inc

Declared extensions of language Python were converted to py: **/*.py

Declared extensions of language TypeScript were converted to ts: /*.ts,/*.tsx

Declared extensions of language JavaScript were converted to js: /*.js,/.jsx,**/.vue

[Info - 17:57:23] Index files

Language of file ‘file:///c:/.component.ts’ is set to ‘ts’

Setting filesystem encoding: UTF-8

[Info - 17:57:23] 1 files indexed

‘PHP sensor’ skipped because there is no related file in current project

‘Analyzer for “php.ini” files’ skipped because there is no related file in current project

‘Python Squid Sensor’ skipped because there is no related file in current project

‘Import of TSLint issues’ skipped because one of the required properties is missing

‘Import of ESLint issues’ skipped because one of the required properties is missing

Execute Sensor: Contextual SonarTS

[Info - 17:57:23] Started SonarTS Analysis


(Elena Vilchik) #3

Hey! when I try your code I get compilation error, are you sure about quotes you used?


(Evan Greensmith) #4

Ha, you’re right. They were regular single quotes in the code. Somewhere along the way they were changed to smart quotes. I’m guessing as I didn’t put them in a preformatted block. It looks like the json config I copied has been changed to smart quotes too.

ngOnInit() {
  alert('hello');
  const password = 'abcde';
  alert('Your password is ' + password);
}

Tried this again with SonarLint 1.5.0 with the above code (hopefully the quotes remain this time)


(Elena Vilchik) #5

I can’t reproduce

Could you send zip with full project? (with tsconfig and package.json)?


(Evan Greensmith) #6

Thanks for taking a look at this.

My original report involved snippets added to a company workspace. I created a new workspace and an associated angular project. I added some equivalent lines to my-app/src/app/app.component.ts
I don’t see any sonarlint warnings.

Here is the project and workspace with node_modules deleted. I’ve uploaded with a .zip.txt extension as zips are not allowed. Hopefully this doesn’t cause problems. Or if there is another way to upload the zip, let me know.

vscode-sonarlint.code-workspace.zip.txt (234.5 KB)

Note that I’m using the latest SonarLint (1.5.0) now, and an updated vscode (1.26.1). I also see a different output for SonarLint. It now states that SonarTS is finished. I also see the line:
‘Import of TSLint issues’ skipped because one of the required properties is missing

Analysis triggered on file:///c%3A/Users/evan/Workspaces/local/vscode-sonarlint/my-app/src/app/app.component.ts with configuration: 
[
  baseDir: c:\Users\evan\Workspaces\local\vscode-sonarlint\my-app
  workDir: c:\Users\evan\Workspaces\local\vscode-sonarlint\my-app\.sonarlint
  extraProperties: {}
  excludedRules: []
  includedRules: []
  inputFiles: [
    c:\Users\evan\Workspaces\local\vscode-sonarlint\my-app\src\app\app.component.ts (UTF-8) [ts]
  ]
]

Starting standalone SonarLint engine...
Using 4 analyzers
Create : C:\Users\evan\.sonarlint\plugins
Plugin cache: C:\Users\evan\.sonarlint\plugins
Create : C:\Users\evan\.sonarlint\plugins\_tmp
Load plugins
Load plugins (done) | time=29ms
Plugins:
  * SonarPHP 2.14.0.3569 (php)
  * SonarPython 1.10.0.2131 (python)
  * SonarTS 1.7.0.2893 (typescript)
  * SonarJS 4.2.0.6476 (javascript)
[Info  - 4:37:17 PM] Starting SonarTS Server
Deploying bundle to C:\Users\evan\.sonarlint\work\.sonartmp_6229908068216082165\4162772358186782293
[Info  - 4:37:32 PM] Using typescript at [C:\Users\evan\node_modules\typescript], version 2.3.4
[Info  - 4:37:32 PM] SonarTS Server is started
[Info  - 4:37:32 PM] SonarTS Server connected to 56047
Standalone SonarLint engine started
Available languages:
  * PHP => "php"
  * Python => "py"
  * TypeScript => "ts"
  * JavaScript => "js"
Start analysis
Declared extensions of language PHP were converted to php: **/*.php,**/*.php3,**/*.php4,**/*.php5,**/*.phtml,**/*.inc
Declared extensions of language Python were converted to py: **/*.py
Declared extensions of language TypeScript were converted to ts: **/*.ts,**/*.tsx
Declared extensions of language JavaScript were converted to js: **/*.js,**/*.jsx,**/*.vue
[Info  - 4:37:33 PM] Index files
Language of file 'file:///c:/Users/evan/Workspaces/local/vscode-sonarlint/my-app/src/app/app.component.ts' is set to 'ts'
Setting filesystem encoding: UTF-8
[Info  - 4:37:33 PM] 1 files indexed
'PHP sensor' skipped because there is no related file in current project
'Analyzer for "php.ini" files' skipped because there is no related file in current project
'Python Squid Sensor' skipped because there is no related file in current project
'Import of TSLint issues' skipped because one of the required properties is missing
'Import of ESLint issues' skipped because one of the required properties is missing
Execute Sensor: Contextual SonarTS
[Info  - 4:37:33 PM] Started SonarTS Analysis
[Info  - 4:37:35 PM] Finished SonarTS Analysis
'SonarJS' skipped because there is no related file in current project

(Elena Vilchik) #7

So your reproducer is not reproducer:)

‘Import of TSLint issues’ skipped because one of the required properties is missing is not related, just to show that issues from external report are not imported (I mean this feature)


(Evan Greensmith) #8

Thanks Elena,
Sounds like the problem is something to do with my environment. Do you know of any additional logging or other tests/directions that could help identify the issue?


(Elena Vilchik) #9

I think, you could try to have a small project reproducing your initial problem, unfinished analysis


(Evan Greensmith) #10

I enabled SonarLint for the original project, and I do still see the unfinished analysis problem. At the moment it’s not clear to me what the critical difference is. So it looks like I have two issues: in the original project the analysis does not finish; in the new project, the analysis does finish but does not display any of the expected results.

I might put this investigation aside for a while: until I have an epiphany on something to try, or I have time to dig in. Thanks for your time looking into this.