Please provide
- Operating system: Windows 10
- IDE name and flavor/env: VSCode in WSL2: Ubuntu-20.04
- SonarLint plugin version: v3.4.0
- Is connected mode used:
- Connected to SonarCloud or SonarQube (and which version): SonaQube Community Version 9.4.0.54424
And a thorough description of the problem / question:
I got a NullPointerException when I ran an analysis of my Python code. This occurred when I connect my SonarLint to the SonarQube which is running as a docker application on my machine. When I removed the “sonarlint.connectedMode.project” entry, the analysis worked fine. This only happened for my VSCode connected to WSL mode. It worked fine when VSCode is connected to Windows cmd mode. Following is the SonarLint logs of this exception:
[Debug - 16:56:59.589] Analysis triggered with configuration:
[
projectKey: projectA
baseDir: /home/gohsl/workspace/python/projectA
extraProperties: {sonar.cfamily.compile-commands=}
moduleKey: file:///home/gohsl/workspace/python/projectA
inputFiles: [
file:///home/gohsl/workspace/python/projectA/headlines.py (UTF-8) [py]
]
]
[Debug - 16:56:59.602] * java: 429 active rules
[Debug - 16:56:59.602] Rule common-java:DuplicatedBlocks is enabled on the server, but not available in SonarLint
[Debug - 16:56:59.606] * web: 27 active rules
[Debug - 16:56:59.606] * xml: 15 active rules
[Debug - 16:56:59.606] * js: 156 active rules
[Debug - 16:56:59.607] * php: 139 active rules
[Debug - 16:56:59.608] Rule common-php:DuplicatedBlocks is enabled on the server, but not available in SonarLint
[Debug - 16:56:59.608] * py: 139 active rules
[Debug - 16:56:59.609] * ts: 146 active rules
[Debug - 16:56:59.679] Start analysis
[Info - 16:56:59.692] Index files
[Debug - 16:56:59.694] Language of file 'file:///home/gohsl/workspace/python/projectA/headlines.py' is set to 'Python'
[Info - 16:56:59.704] 1 file indexed
[Debug - 16:56:59.985] 'JavaSensor' skipped because there is no related files in the current project
[Debug - 16:56:59.985] Execute Sensor: HTML
[Debug - 16:56:59.987] 'CFamily' skipped because there is no related files in the current project
[Debug - 16:56:59.987] 'JavaScript analysis' skipped because there is no related files in the current project
[Debug - 16:56:59.988] 'TypeScript analysis' skipped because there is no related files in the current project
[Debug - 16:56:59.988] Execute Sensor: Python Sensor
[Warn - 16:56:59.990] No workDir in SonarLint
[Debug - 16:56:59.998] Language of file 'file:///home/gohsl/workspace/python/projectA/headlines.py' is detected to be 'Python'
[Debug - 16:57:00.001] Cached Java config for file 'file:///home/gohsl/workspace/python/projectA/annotations.py'
[Debug - 16:57:00.002] Language of file 'file:///home/gohsl/workspace/python/projectA/annotations.py' is detected to be 'Python'
[Debug - 16:57:00.003] Cached Java config for file 'file:///home/gohsl/workspace/python/projectA/after_black.py'
[Debug - 16:57:00.004] Language of file 'file:///home/gohsl/workspace/python/projectA/after_black.py' is detected to be 'Python'
[Debug - 16:57:00.005] Cached Java config for file 'file:///home/gohsl/workspace/python/projectA/before_black.py'
[Debug - 16:57:00.006] Language of file 'file:///home/gohsl/workspace/python/projectA/before_black.py' is detected to be 'Python'
[Debug - 16:57:00.011] Initializing metadata of file file:///home/gohsl/workspace/python/projectA/headlines.py
[Debug - 16:57:00.013] Initializing metadata of file file:///home/gohsl/workspace/python/projectA/annotations.py
[Debug - 16:57:00.013] Initializing metadata of file file:///home/gohsl/workspace/python/projectA/after_black.py
[Debug - 16:57:00.014] Initializing metadata of file file:///home/gohsl/workspace/python/projectA/before_black.py
[Debug - 16:57:00.015] Input files for indexing: [[uri=file:///home/gohsl/workspace/python/projectA/headlines.py], [uri=file:///home/gohsl/workspace/python/projectA/annotations.py], [uri=file:///home/gohsl/workspace/python/projectA/after_black.py], [uri=file:///home/gohsl/workspace/python/projectA/before_black.py]]
[Info - 16:57:00.016] Starting global symbols computation
[Info - 16:57:00.017] 4 source files to be analyzed
[Info - 16:57:00.268] 4/4 source files have been analyzed
[Info - 16:57:00.268] Starting rules execution
[Info - 16:57:00.268] 1 source file to be analyzed
[Debug - 16:57:00.358] Initializing metadata of file file:///home/gohsl/workspace/python/projectA/headlines.py
[Info - 16:57:00.370] 1/1 source file has been analyzed
[Debug - 16:57:00.370] 'PHP sensor' skipped because there is no related files in the current project
[Debug - 16:57:00.370] 'Analyzer for "php.ini" files' skipped because there is no related files in the current project
[Debug - 16:57:00.370] 'XML Sensor' skipped because there is no related files in the current project
[Debug - 16:57:00.370] Execute Sensor: Sonar Secrets Detection Sensor
[Error - 16:57:00.375] Analysis failed
java.lang.NullPointerException
at org.sonarsource.sonarlint.ls.folders.WorkspaceFolderBranchManager.getReferenceBranchNameForFolder(WorkspaceFolderBranchManager.java:100)
at org.sonarsource.sonarlint.ls.connected.ProjectBindingManager.lambda$computeProjectBinding$5(ProjectBindingManager.java:208)
at org.sonarsource.sonarlint.ls.connected.ServerIssueTrackerWrapper.matchAndTrack(ServerIssueTrackerWrapper.java:72)
at org.sonarsource.sonarlint.ls.AnalysisTaskExecutor.lambda$analyzeConnected$27(AnalysisTaskExecutor.java:454)
at java.base/java.util.HashMap.forEach(Unknown Source)
at org.sonarsource.sonarlint.ls.AnalysisTaskExecutor.lambda$analyzeConnected$28(AnalysisTaskExecutor.java:451)
at org.sonarsource.sonarlint.ls.AnalysisTaskExecutor.analyzeWithTiming(AnalysisTaskExecutor.java:493)
at org.sonarsource.sonarlint.ls.AnalysisTaskExecutor.analyzeConnected(AnalysisTaskExecutor.java:449)
at org.sonarsource.sonarlint.ls.AnalysisTaskExecutor.analyzeSingleModuleNonExcluded(AnalysisTaskExecutor.java:318)
at org.sonarsource.sonarlint.ls.AnalysisTaskExecutor.analyzeSingleModule(AnalysisTaskExecutor.java:268)
at org.sonarsource.sonarlint.ls.AnalysisTaskExecutor.analyze(AnalysisTaskExecutor.java:192)
at org.sonarsource.sonarlint.ls.AnalysisTaskExecutor.analyze(AnalysisTaskExecutor.java:160)
at org.sonarsource.sonarlint.ls.AnalysisTaskExecutor.lambda$analyze$4(AnalysisTaskExecutor.java:139)
at java.base/java.util.HashMap.forEach(Unknown Source)
at org.sonarsource.sonarlint.ls.AnalysisTaskExecutor.analyze(AnalysisTaskExecutor.java:139)
at org.sonarsource.sonarlint.ls.AnalysisTaskExecutor.run(AnalysisTaskExecutor.java:116)
at org.sonarsource.sonarlint.ls.AnalysisScheduler.lambda$analyzeAsync$1(AnalysisScheduler.java:185)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.base/java.util.concurrent.FutureTask.run(Unknown Source)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.base/java.lang.Thread.run(Unknown Source)
[Debug - 16:57:37.416] GET 200 http://sonarqube:9000/api/developers/search_events?projects=projectA&from=2022-04-10T16%3A57%3A37%2B0800 | response time=64ms
[Debug - 16:58:37.356] GET 200 http://sonarqube:9000/api/developers/search_events?projects=projectA&from=2022-04-10T16%3A57%3A37%2B0800 | response time=8ms
[Debug - 16:59:37.357] GET 200 http://sonarqube:9000/api/developers/search_events?projects=projectA&from=2022-04-10T16%3A57%3A37%2B0800 | response time=8ms
[Debug - 17:00:37.357] GET 200 http://sonarqube:9000/api/developers/search_events?projects=projectA&from=2022-04-10T16%3A57%3A37%2B0800 | response time=9ms
[Debug - 17:01:37.357] GET 200 http://sonarqube:9000/api/developers/search_events?projects=projectA&from=2022-04-10T16%3A57%3A37%2B0800 | response time=9ms
[Debug - 17:02:37.358] GET 200 http://sonarqube:9000/api/developers/search_events?projects=projectA&from=2022-04-10T16%3A57%3A37%2B0800 | response time=9ms
[Debug - 17:03:37.356] GET 200 http://sonarqube:9000/api/developers/search_events?projects=projectA&from=2022-04-10T16%3A57%3A37%2B0800 | response time=8ms
[Debug - 17:04:37.356] GET 200 http://sonarqube:9000/api/developers/search_events?projects=projectA&from=2022-04-10T16%3A57%3A37%2B0800 | response time=7ms
[Debug - 17:05:37.358] GET 200 http://sonarqube:9000/api/developers/search_events?projects=projectA&from=2022-04-10T16%3A57%3A37%2B0800 | response time=9ms
[Debug - 17:06:37.356] GET 200 http://sonarqube:9000/api/developers/search_events?projects=projectA&from=2022-04-10T16%3A57%3A37%2B0800 | response time=6ms
[Debug - 17:07:37.357] GET 200 http://sonarqube:9000/api/developers/search_events?projects=projectA&from=2022-04-10T16%3A57%3A37%2B0800 | response time=8ms
[Debug - 17:08:37.356] GET 200 http://sonarqube:9000/api/developers/search_events?projects=projectA&from=2022-04-10T16%3A57%3A37%2B0800 | response time=7ms
[Debug - 17:09:37.356] GET 200 http://sonarqube:9000/api/developers/search_events?projects=projectA&from=2022-04-10T16%3A57%3A37%2B0800 | response time=7ms
[Debug - 17:10:37.357] GET 200 http://sonarqube:9000/api/developers/search_events?projects=projectA&from=2022-04-10T16%3A57%3A37%2B0800 | response time=7ms
[Debug - 17:11:37.360] GET 200 http://sonarqube:9000/api/developers/search_events?projects=projectA&from=2022-04-10T16%3A57%3A37%2B0800 | response time=12ms
[Debug - 17:12:37.356] GET 200 http://sonarqube:9000/api/developers/search_events?projects=projectA&from=2022-04-10T16%3A57%3A37%2B0800 | response time=7ms
[Debug - 17:12:55.295] Queuing analysis of file 'file:///home/gohsl/workspace/python/projectA/projectA.code-workspace' (version 1)
Error on git command ""git" check-ignore projectA.code-workspace": Error: Command failed: "git" check-ignore projectA.code-workspace
fatal: not a git repository (or any of the parent directories): .git
[Debug - 17:12:55.326] Cached SCM ignore status for file 'file:///home/gohsl/workspace/python/projectA/projectA.code-workspace'
[Info - 17:12:55.330] Analyzing file 'file:///home/gohsl/workspace/python/projectA/projectA.code-workspace'...
[Debug - 17:12:55.331] Analysis triggered with configuration:
[
projectKey: projectA
baseDir: /home/gohsl/workspace/python/projectA
extraProperties: {sonar.cfamily.compile-commands=}
moduleKey: file:///home/gohsl/workspace/python/projectA
inputFiles: [
file:///home/gohsl/workspace/python/projectA/projectA.code-workspace (UTF-8)
]
]
Has anyone encountered this before?