Sonarlint not working on connected mode

  • Operating system: Windows 11
  • SonarLint plugin version: v4.10.0
  • Programming language you’re coding in: python
  • Is connected mode used:yes
    • Connected to SonarCloud or SonarQube (and which version): sonarqube CE, 10.6

And a thorough description of the problem / question:

Hi everyone, I’m using SonarLint, and it works fine in standalone mode. However, when I connect to the SonarQube server, the analyses stop working and don’t run. If I unbind the project, SonarLint works fine again. I enabled the log level, and the only strange log that appears is:

File exclusion for uri 'file:///c:/Users/rocki/Documents/programming/projects/python/pages/models.py' is false
[Debug - 08:26:50.832] isReadyForAnalysis(connectionId: https-sonarqube, sonarProjectKey: id, plugins: true, analyzer config: true, findings: false) => false
[Debug - 08:26:51.122] Language of file "file:///c:/Users/rocki/Documents/programming/project/python/pages/models.py" is detected to be "PYTHON"
[Debug - 08:26:51.225] Module file event for MODIFIED for file [uri=file:///c:/Users/rocki/Documents/programming/project/python/pages/models.py] has been ignored because it's not a Kubernetes file.
[Debug - 08:26:51.226] Computing file exclusion for uri 'file:///c:/Users/rocki/Documents/programming/project/python/pages/models.py'
[Debug - 08:26:51.232] isReadyForAnalysis(connectionId: https-sonarqube, sonarProjectKey: id, plugins: true, analyzer config: true, findings: false) => false
[Debug - 08:26:51.233] File exclusion for uri 'file:///c:/Users/rocki/Documents/programming/project/python/pages/models.py' is false
[Debug - 08:27:09.144] GET 200 https://sonarqube/api/developers/search_events?projects=&from= | response time=102ms
[Debug - 08:27:09.392] GET 200 https://sonarqube/api/developers/search_events?projects=id&from=2024-09-25T08%3A27%3A09-0300 | response time=202ms

I think it’s not analyzing because of that: “it’s not a Kubernetes file.” Is there a way to change that?

Hi there @rolandsgs, welcome! :sonar: :wave:

Thanks for the post. The real reason why analysis is not happening is
isReadyForAnalysis(connectionId: https-sonarqube, sonarProjectKey: id, plugins: true, analyzer config: true, findings: false) => false

In Connected Mode, SonarLint synchronizes with the SonarQube server. Local analysis can be performed once the synchronization is complete and the “analysis readiness” returns true. Now to understand exactly WHY analysis is never getting ready in your case, we would need full SonarLint logs. The first line should look something like: Executing /Library/Java/JavaVirtualMachines/jdk-17.jdk/Contents/Home/bin/java -jar

Thanks in advance,
Sophio

Thank you so much, Sophio.
Investigating more the logs, using the project token, thats the output:

[Debug - 08:09:45.155] Cleanup of the plugin storage in folder C:\Users\rocki\.sonarlint\storage\6874747073d6e6565732d7566616c2d62722d\plugins, 0 unknown files
[Debug - 08:09:45.185] Connecting to server event-stream at 'api/push/sonarlint_events?projectKeys=id&languages=apex,c,cpp,cs,css,cobol,web,ipynb,java,js,php,plsql,py,secrets,tsql,ts,xml,yaml,json,go,cloudformation,docker,kubernetes,terraform,azureresourcemanager'...
[Debug - 08:09:45.235] GET 200 https://sonarqube/api/system/status | response time=1107ms
[Debug - 08:09:45.235] Downloaded server infos in 1111ms
[Debug - 08:09:45.236] GET 403 https://sonarqube/api/components/tree.protobuf?qualifiers=FIL,UTS&component=id&ps=50&p=1 | response time=479ms
[Debug - 08:09:45.242] Error while getting server file paths for project 'id'
[Debug - 08:09:45.244] java.lang.IllegalStateException: Insufficient privileges

I changed the token from the project analysis token to the user token, and the analysis worked

isReadyForAnalysis(connectionId: https-sonarqube, sonarProjectKey: id, plugins: true, analyzer config: true, findings: true) => true

i thought it should work with PAT

I changed the token from the project analysis token to the user token, and the analysis worked

Awesome! Indeed, based on our docs, SonarLint requires a User Token for Connected Mode setup.

All the best,
Sophio :blush:

1 Like