Sonarlint don't show warnings and alerts

Hi team,
I installed the way next:

  • VSCode 1.55.2
    +Sonarlint extension 1.21.0
  • Sonarqube 8.8.0.42792
  • Java 11 (Sonarlint dont on in Java 8)
  • code in Java 11 (I donwloaded demo in https://start.spring.io/ )

additional, i see the message “couldn’t start client sonarlint language server” in the VSCode.

I Attach screenshots code without any alerts or warnings in the VSCode and Sonarlint.

@j4v13r

Hello, welcome to the community! And thank you for your question.

Could you please have a look at the SonarLint Output? This should give you additional info about what prevents the Language Server from starting.

SonarLint’s language server relies on the availability of a JRE; if it is on your machine’s $PATH it should find it automatically, else you can specify the path the the JRE in your settings, using property sonarlint.ls.javaHome.

You might also want to have a look at the pinned FAQ, it contains a lot of information that can be useful to get started.

Hi,
I using the following version:

  • VSCode 1.55.2
    +Sonarlint extension 1.21.0
  • Sonarqube 8.2
  • Java 8
  • code in Java 8

The SonarLint show of the issues in the Output:


My connected server Sonar is enable, the command is:
{

"sonarlint.connectedMode.connections.sonarqube": [
    { "serverUrl": "http://xxxxxx.xxxxxx.azure.com:9000/", 
      "token": "a502283eca4a1753f29xxxxxxxxxxxxxxxxxx" }
],
"editor.suggestSelection": "first",
"vsintellicode.modify.editor.suggestSelection": "automaticallyOverrodeDefaultValue",
"files.exclude": {
    "**/.classpath": true,
    "**/.project": true,
    "**/.settings": true,
    "**/.factorypath": true
},
"sonarlint.connectedMode.project": 
{
    "projectKey": "com.example:demo"
},
"sonarlint.analyzerProperties": {
},
"sonarlint.rules": {
    "java:S2637": {
        "level": "off"
    },
    "java:S1161": {
        "level": "off"
    },
    "java:S3751": {
        "level": "off"
    },
    "java:S4602": {
        "level": "off"
    },
    "java:S4604": {
        "level": "on"
    },
    "java:S4603": {
        "level": "on"
    }
},
"sonarlint.ls.javaHome": "C:\\Program Files\\Java\\jdk1.8.0_291",
"sonarlint.output.showAnalyzerLogs": true,
"sonarlint.output.showVerboseLogs": true

}

Any recommends.

Thanks,

Hello, thanks for the additional details.

First, I would advise that you update to the freshly released SonarQube 8.9 LTS if you can, to get the latest versions of the analyzers :slight_smile: and a lot of new features.

Second, you’ll want to move the sonarlint.connectedMode.project block in your project settings (under .vscode/settings.json).

Finally, what kind of issues/warnings do you expect to see in the DemoApplication.java file that you posted in your initial message? I’m not sure what kind of issues should be raised according to your quality profile.

I’m taking note of the 404 returned by the notification API, this should not have any impact on which issues are found (and it should disappear if you upgrade to a more recent version of SonarQube).

1 Like

Hello Jean-Baptiste,

1.- I can not change the version of SonarQube because it is the one currently used in production. Yes it would be great, but for the moment it is not possible.

2.- Where do I move the sonarlint.connectedMode.project, I don’t understand your recommendation. If you can clarify it please.

3.- What I hope is that when I run a code smell, SonarLint warns me.

4.- Perfect, thanks for the analysis.

Thank You,

Hello, one additional piece of information,
In the first box in red, I see that it skips the file analysis and repeats and repeats, I noticed that in the logs. And in the second as it does not connect to my SonarQube and therefore I understand that it does not download the rules .

Hi,
I change config of SonarLint from User and workspace:

User:
{
“sonarlint.connectedMode.connections.sonarqube”: [
{ “serverUrl”: “http://xxxxxxxxxx.cloudapp.azure.com:9000/”,
“token”: “a502283xxxxxxxecxxxxxxxxxxxxxxxxxxxb1ba91”
],
“editor.suggestSelection”: “first”,
“vsintellicode.modify.editor.suggestSelection”: “automaticallyOverrodeDefaultValue”,
}

Config workspace:
{
“sonarlint.connectedMode.project”:
{“projectKey”: “com.example:demo”}
}

Now I see this logs in the Output Sonarlint:

it seems that it does not connect to my external sonarqube or what could be happening, because it still does not show me the Sonarint warnings when I encode.

I see that error after that restart VScode.

Help, please.

Hello, this has nothing to do with SonarLint. Those are warnings generated by the vscode-java extension.

What kinds of issues do you expect SonarLint to detect in the source code snippet that you shared? I don’t see any reason for there to be any code smell in what looks like a very basic Spring (Boot?) main method.

Hello,
after turning around several installations, I realized that everything was working fine. The problem was that as I did not put harmful code, SonarLint did not alert; then I started coding incorrectly and I managed to see warnings and I was more than satisfied. Here, thanks to your configuration recommendations, I was able to make some changes.

One last question, how can I validate that the SonarLint was connected to the external SonarQube by command or other method, apart from the connection established in the Connection Mode.

Hey, glad that you got it to work!

As far as I can tell, there is no dedicated command to check that the connected mode setup is valid - and this could be a nice improvement for a future version.

As a workaround, you can rely on command “SonarLint: Update all project bindings to SonarQube/SonarCloud” (with ID SonarLint.UpdateAllBindings), which should at the very least try to check that the local settings are up-to-date with the server; it should show a few notifications during the process that can prove useful in troubleshooting.

Yes, with that command at the end I get that the whole build completed successfully. But it would be nice to have a command to do the exact validation.

Thank you very much, it was a good experience. I will come back with the doubts when I try Gradle hehehe.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.