Sonarlint for Visual Code is not displaying anything for Java after binding

Hi there, new to the community so please let me know if I am breaking any rules.

I am trying to get Sonarlint (v1.15.0) configured with Visual Code (v1.42.0) connected to an on-prem community version of Sonarqube server (v7.9.1).

I have configured the workspace and user settings in Visual Code as per the below (redacted but I hope it gets the point across):

Workspace:

    "sonarlint.connectedMode.project": {
        "projectKey": "**(ID)**"
    }
}

User:

    "sonarlint.connectedMode.connections.sonarqube": [
         { "serverUrl": "http://**(URL)**:9000/", 
          "token": "**(token)**" }
    ]
}

It is by my understanding and by following all the instructions I can find, that when I update all project bindings I should now be seeing underlines in my test code but this is not the case for my Java files. In the output I have the following error:

[Debug - 13:55:31.623] Skipping analysis of Java file 'file:///**(x)**' because SonarLint was unable to query project configuration (classpath, source level, ...)

Hoping you can let me know if I am missing something.

Thanks in advance!

Hi,

SonarLint needs to access the project classpath to analyze your Java files. To do that we are querying the VSCode Java extension. Could you check you are using a recent version of vscode-java?
Also be sure your project is totally imported.

If that still doesn’t work, please enable both Java LSP debug logs (by settings property java.trace.server to verbose). This will show very verbose messages in the “Language Server for Java” Output.
If everything works fine, you should fins in logs something like:

[Trace - 09:47:29] Sending request 'workspace/executeCommand - (45)'.
Params: {
    "command": "java.project.getClasspaths",
    "arguments": [
        "file:///c%3A/Prog/Projects/scanners/sonar-scanner-cli/src/main/java/org/sonarsource/scanner/cli/Main.java",
        "{\"scope\":\"runtime\"}"
    ]
}

Then the response:

[Trace - 09:47:29] Received response 'workspace/executeCommand - (45)' in 17ms.
Result: {
    "projectRoot": "file:/C:/Prog/Projects/scanners/sonar-scanner-cli",
    "classpaths": [
        "C:\\Prog\\Projects\\scanners\\sonar-scanner-cli\\target\\classes",
        "C:\\Users\\Julien\\.m2\\repository\\org\\sonarsource\\scanner\\api\\sonar-scanner-api\\2.10.0.1189\\sonar-scanner-api-2.10.0.1189.jar",
        "C:\\Users\\Julien\\.m2\\repository\\com\\google\\code\\findbugs\\jsr305\\2.0.3\\jsr305-2.0.3.jar"
    ],
    "modulepaths": []
}

This worked for me after setting the java.home value in my settings.json file:

"java.home": "C:\\Program Files\\Java\\jdk-a.b.c"

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