Change JS Quality Profile into VSCode Sonarlint extension

sonarlint
vscode
sonarqube

(Daniele Leoni) #1

Hi guys,

we have sonarqube configured to use JS.
Sonar Way recommended.

I configured VSCode extension, but I think it is using still the default quality profile.

Is there any property to change?

Thanks

Daniele


(Colin Mueller) #2

Hey Daniele,

Are you using Connected Mode?

Colin


(Daniele Leoni) #3

Yes,

I used these props

"sonarlint.ls.javaHome": "/Library/Java/JavaVirtualMachines/jdk1.8.0_162.jdk/Contents/Home",
"sonarlint.connectedMode.servers": [{
    "serverUrl": "http://localhost:9000",
    "serverId": "BF41A1F2-AWanqvCWvyZ-0DNE4bxx",
    "token": "3cb5cac724e0951e113d74e71bf1015ee48bb5xx",
    "projectKey": "sonar:sei:1.0.0"
}],

(Colin Mueller) #4

Thanks Daniele.

  1. You mentioned you think it’s still using the default profile, what evidence is leading you to that conclusion?

  2. Have you tried updating your bindings?

  3. Anything interesting in the SonarLint output panel?

Cheers,

Colin


(Daniele Leoni) #5

Already tried with update binding.
I have this opinion, because I miss the most simple rules, for example
["===" and "!==" should be used instead of "==" and "!="]
https://sonarcloud.io/organizations/opensource/rules?open=javascript%3AEqEqEq&rule_key=javascript%3AEqEqEq

Following sonarLint output

[Info  - 2:10:44 PM] Using typescript at [/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript], version 3.1.4
[Info  - 2:10:44 PM] SonarTS Server is started
Successfully updated global storage of server BF41A1F2-AWanqvCWvyZ-0DNE4bxx
[Info  - 2:10:44 PM] SonarTS Server connected to 59313
[Info  - 2:10:46 PM] SonarTS Server is stopped
Starting connected SonarLint engine for BF41A1F2-AWanqvCWvyZ-0DNE4bxx...
Create : /Users/danieleleoni/.sonarlint/plugins
Plugin cache: /Users/danieleleoni/.sonarlint/plugins
Create : /Users/danieleleoni/.sonarlint/plugins/_tmp
Load plugins
Load plugins (done) | time=7ms
Plugins:
  * SonarPython 1.10.0.2131 (python)
  * SonarJava 5.6.1.15064 (java)
  * SonarKotlin 1.0.1.965 (kotlin)
  * SonarPHP 2.14.0.3569 (php)
  * SonarTS 1.7.0.2893 (typescript)
  * SonarJS 4.2.0.6476 (javascript)
[Info  - 2:10:46 PM] Using storage for server 'BF41A1F2-AWanqvCWvyZ-0DNE4bxx' (last update 11/24/18 2:10 PM)
[Info  - 2:10:46 PM] Starting SonarTS Server
Deploying bundle to /Users/danieleleoni/.sonarlint/work/.sonartmp_680573692039227686/7913035743322581671
[Info  - 2:10:47 PM] Using typescript at [/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript], version 3.1.4
[Info  - 2:10:47 PM] SonarTS Server is started
Connected SonarLint engine started for BF41A1F2-AWanqvCWvyZ-0DNE4bxx
Updating global storage of server BF41A1F2-AWanqvCWvyZ-0DNE4bxx, may take some time...
[Info  - 2:10:47 PM] SonarTS Server is stopped
Create : /Users/danieleleoni/.sonarlint/plugins
Plugin cache: /Users/danieleleoni/.sonarlint/plugins
Create : /Users/danieleleoni/.sonarlint/plugins/_tmp
GET 200 http://localhost:9000/api/system/status | time=7ms
GET 200 http://localhost:9000/api/plugins/installed | time=5ms
GET 200 http://localhost:9000/api/settings/values.protobuf | time=10ms
Code analyzer 'scmgit' is not compatible with SonarLint. Skip downloading it.
Code analyzer 'ldap' is not compatible with SonarLint. Skip downloading it.
Code analyzer 'csharp' is not compatible with SonarLint. Skip downloading it.
Code analyzer 'cssfamily' is not compatible with SonarLint. Skip downloading it.
Code analyzer 'flex' is not compatible with SonarLint. Skip downloading it.
Code analyzer 'go' is not compatible with SonarLint. Skip downloading it.
Code analyzer 'xml' is not compatible with SonarLint. Skip downloading it.
Code analyzer 'scmsvn' is not compatible with SonarLint. Skip downloading it.
GET 200 http://localhost:9000/api/rules/search.protobuf?f=repo,name,severity,lang,htmlDesc,htmlNote,internalKey,isTemplate,templateKey,actives&statuses=BETA,DEPRECATED,READY&p=1&ps=500 | time=382ms
GET 200 http://localhost:9000/api/rules/search.protobuf?f=repo,name,severity,lang,htmlDesc,htmlNote,internalKey,isTemplate,templateKey,actives&statuses=BETA,DEPRECATED,READY&p=2&ps=500 | time=331ms
GET 200 http://localhost:9000/api/rules/search.protobuf?f=repo,name,severity,lang,htmlDesc,htmlNote,internalKey,isTemplate,templateKey,actives&statuses=BETA,DEPRECATED,READY&p=3&ps=500 | time=268ms
GET 200 http://localhost:9000/api/rules/search.protobuf?f=repo,name,severity,lang,htmlDesc,htmlNote,internalKey,isTemplate,templateKey,actives&statuses=BETA,DEPRECATED,READY&p=4&ps=500 | time=256ms
GET 200 http://localhost:9000/api/qualityprofiles/search.protobuf | time=42ms
GET 200 http://localhost:9000/api/components/search.protobuf?qualifiers=TRK,BRC&ps=500&p=1 | time=12ms
Create : /Users/danieleleoni/.sonarlint/plugins
Plugin cache: /Users/danieleleoni/.sonarlint/plugins
Create : /Users/danieleleoni/.sonarlint/plugins/_tmp
Load plugins
Load plugins (done) | time=4ms
Plugins:
  * SonarPython 1.10.0.2131 (python)
  * SonarJava 5.6.1.15064 (java)
  * SonarKotlin 1.0.1.965 (kotlin)
  * SonarPHP 2.14.0.3569 (php)
  * SonarTS 1.7.0.2893 (typescript)
  * SonarJS 4.2.0.6476 (javascript)
[Info  - 2:10:49 PM] Using storage for server 'BF41A1F2-AWanqvCWvyZ-0DNE4bxx' (last update 11/24/18 2:10 PM)
[Info  - 2:10:49 PM] Starting SonarTS Server
Deploying bundle to /Users/danieleleoni/.sonarlint/work/.sonartmp_396192211960833654/872184421238574667
[Info  - 2:10:50 PM] Using typescript at [/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript], version 3.1.4
[Info  - 2:10:50 PM] SonarTS Server is started
Successfully updated global storage of server BF41A1F2-AWanqvCWvyZ-0DNE4bxx
[Info  - 2:10:50 PM] SonarTS Server connected to 59323

I cannot see anything wrong
But how could we check if it is really connected to the local server and not using just default rules as not connected server?

Thank you for your time!


(Colin Mueller) #6

Daniele,

I just reviewed your configuration again and realized that you are defining your settings a little bit wrong (and by “realized”, I mean I realized I’ve never set up Connected Mode in VSCode before. I just fixed that!).

Here’s an example configuration that separates sonarlint.connectedMode.servers from sonarlint.connectedMode.project, where the serverId from sonarlint.connectedMode.servers is referenced.

{  
   "sonarlint.connectedMode.servers":[  
      {  
         "serverUrl":"http://localhost:9000",
         "serverId":"BF41A1F2-AWanqvCWvyZ-0DNE4bxx",
         "token":"3cb5cac724e0951e113d74e71bf1015ee48bb5xx"
      }
   ],
   "sonarlint.connectedMode.project":{  
      "serverId":"BF41A1F2-AWanqvCWvyZ-0DNE4bxx",
      "projectKey":"sonar:sei:1.0.0"
   }
}

Give that a try and let me know.

Colin


(Daniele Leoni) #7

Thanks! It seems to work now!
I did not really understand this is the right way reading documentation.

Thanks!