Troubleshooting

What to do when you have problems running an analysis in SonarQube for VS Code.

Knowing where to begin looking for information is the first step to reaching out for help. Many answers to commonly found problems can be found on the SonarQube for IDE channel of the Sonar community forumarrow-up-right. See below for the basic steps to access the SonarQube for IDE logs when the analysis results are not what you expected.

Before posting to the Community, make sure that you have your logs ready by following the instructions below.

How to get SonarQube for IDE logs

  • Open the SonarQube for VS Code extension settings window: Manage (-) > Settings > Extensions > SonarLint (or Code > Settings… > Settings [⌘,] in macOS)

  • In the extension settings, enable the SonarLint > Output: Show Verbose Logs option.

Where to turn on Verbose output for your logs when troubleshooting SonarQube for VS Code.
  • Then, switch the output in the VSCode console: OUTPUT > SonarQube for IDE

Switch your OUTPUT to SonarQube for IDE to see the Analyzer logs and Verbose output.

How to get SonarQube for VS Code thread dumps

In some cases, it can be useful to extract thread dumps from the running instance of your IDE for debugging; thread dumps can help us investigate UI freeze issues or threading problems.

If SonarQube for IDE does not start or stops working and the IDE is still running, thread dumps are necessary to properly troubleshoot the problem before the IDE is restarted. If you restart the IDE, some information about what was happening when it failed will be lost. Fortunately, thread dumps are easy to obtain for both SonarQube for IDE and your IDE.

  1. While SonarQube for VS Code is running, run jps in your terminal to see a list of process IDs (PID).

  2. Note the PID of sonarlint-ls.jar.

  3. Run jstack <PID> to get the thread dump.

Once obtained, please report your error to the Community forumarrow-up-right. Your thread dump may contain sensitive details and if it’s required for further troubleshooting, it will be possible to share your thread dump privately.

The VS Code Developer Tools Console

In addition, the VS Code Developer Tools Console can provide more information when troubleshooting.

  • Go to Help > Toggle Developer Tools > Console in VSCode

  • Clear your console.

  • Reproduce the issue you encountered and check the output.

  • A screenshot of your error may be helpful when posting to the SonarQube for VS Code communityarrow-up-right.

Configuring your JRE

SonarQube for VS Code requires a JRE to run and it's typically downloaded if a correct version is not found locally. Check the Overview on the Requirements page for full details on how this works.

Signs that you may not have an approved JRE include notifications such as SonarLint Language Server client: couldn't create connection to server and/or Java 17 or more recent is required to run. Please download and install a recent JRE.

It could be that your installation of SonarQube for VS Code may have inadvertently been updated to a universal version which does not include the embedded JRE. Ideally, you should install a platform-specific version that fulfills your system requirements.

How to check your installation:

  • Open the SonarQube for IDE extension page within VS Code and hover your mouse over the Size attribute.

  • You are all set if the installation path in the popup includes a platform identifier, for example, win32-x64, linux-x64, or darwin-arm64.

  • If needed, select the Size attribute to open the containing folder (then look for the platform identifier).

If those identifiers are missing, you may have to fix the installation. Simply update to the latest SonarQube for VS Code version or, if you really want to be certain it works, uninstall and reinstall the extension to prompt the download of an approved JRE.

As always, reach out to the Communityarrow-up-right if you're still experiencing problems.

Troubleshooting your connected mode setup

No matching project found

No matching project is found because:

  • It’s best if you already have the project open in your IDE, otherwise SonarQube for IDE might not be able to find a matching file.

  • SonarQube for IDE can get confused if you have more than one project open in different windows. Please close the non-applicable project and try again.

If these solutions don’t help, follow the instructions for Project binding to manually configure your project binding.

No matching issue found

SonarQube for IDE can’t find your issue because:

  • You might not be on the same branch.

  • The issue was fixed, or the source code may be different from the analyzed version.

Troubleshooting unexpected analysis results

Sometimes, issues found on the server differ from those found locally by SonarQube for IDE. Usually, the server-side rule configuration (your quality profile) is to blame; however, it could be something more than that. Maybe your local build configuration and system dependencies don’t align with your DevOps pipeline, or it could simply be that the issue, due to its complexity, is only detectable by SonarQube Server or SonarQube Cloud.

The collapsible below lists some of the most commonly encountered reasons, along with some details that will help you troubleshoot discrepancies.

chevron-rightWhy your local analysis might be different than found on the serverhashtag

Some issues might be detected by third-party analyzers

SonarQube for IDE will only run rules from Sonar analyzersarrow-up-right including custom rules extending Sonar analyzersarrow-up-right. Third-party analyzers usually have their own IDE integration, and there is no plan to run them inside of SonarQube for IDE.

Your test files might be mistaken as source files

Test files can be defined in SonarQube (Server, Cloud) or SonarQube Community Build at either the project or global levels. In addition, test files can be defined in the IDE however, each IDE handles test files a bit differently:

  • For example, SonarQube for Visual Studio does not distinguish between project and test code, and SonarQube for IntelliJ relies on the IDE to detect if a file is a test file. In the case where the IntelliJ IDE detects the test file for SonarQube for IntelliJ:

    • The file is under a test sources root. Those roots can be manually created by users or automatically populated by the IDE by relying on the build system such as Maven or Gradle, for example.

    • The file is flagged as a test file by any plugin that you have installed. The IDE bundles some internal plugins like the "JavaScript and TypeScript" plugin; these internal plugins can infer if a file should be considered as a test file. Third-party plugins can also infer test files, and SonarQube for IDE will recognize these as such.

Please review your IDE's page about File exclusions and check these pages to define your analysis scope on the server:

Some rules are too complex to run locally

Some rules can report issues at the project level or require extensive resources to analyze, such as injection vulnerabilities and some advanced bug detection rules; such issues are not displayed in SonarQube for IDE, only in SonarQube (Server, Cloud). Please check the SonarQube for IDE roadmaparrow-up-right for a list of features on the horizon and review the server documentation to understand more about these issue types:

File or language types are not supported

Check your IDE’s Rules and languages page for a list of supported languages and file types.

The analyzer version may be different

Improvements are constantly being made to the Sonar analyzers during the CI/CD development cycle. Depending on the product version you are running, you may have a different analyzer therefore, the results might be different.

  • SonarQube Cloud is always running the latest analyzers.

  • SonarQube Server and SonarQube Community Build runs the latest available analyzer at the time of its release.

  • SonarQube for IDE runs the latest available analyzer at the time of its release.

  • Sometimes SonarQube for IDE downloads and uses the same SonarQube Server or SonarQube Cloud analyzer when running in connected mode.

Your project configuration may be different

Discrepancies in C and C++ analysis may result from different project builds and system dependencies. For example, you might have one set up in your local build configuration and another set up for your CI build configuration (or the configuration created by Autoscan).

There are no issues in your PROBLEMS panel

If you’re not seeing issues in your PROBLEMS panel, and the logs suggest that there is some sort of data corruption, it’s possible that the SonarQube for IDE issue storage was corrupted and the cache needs to be cleared.

To fix this, you can delete these folders and reload the IDE window:

  • ~/.sonarlint/.sonarlinttmp*

  • ~/.sonarlint/storage/h2

Open in IDE

chevron-rightUsing Open in IDE with VS Code and WSLhashtag

Troubleshooting Open in IDE with WSL

The Open in IDE feature from SonarQube Server and Cloud tries to access http://localhost:<PORT>, where <PORT> is between 64120 and 64130. If you are developing in Windows Subsystem for Linux (WSL), the SonarQube for IDE language server is running within WSL and not on Windows therefore, the connection fails. See the Opening issues in the IDE article for more information about how the feature works normally.

In WSL2, there is a new network mode: mirrored. This mode tells WSL to “share” the network connections with Windows which allows Open in IDE to work as expected.

You need to have a file called .wslconfig in your Windows home directory that contains the following:

Restart after running the distribution.

More information about this setting is available from Microsoftarrow-up-right.

FAQ

Are my SonarScanner properties applied to SonarQube for IDE?

No. Scanner properties you may have defined in the sonar-project.properties or pom.xml files (for example sonar.sources or sonar.projectBasedir) only make sense when using the SonarScanner in the command line. SonarQube for IDE tries to use IDE metadata to avoid other configurations.

If you want to share some configuration between SonarScanners and SonarQube for IDE, like File exclusions or some specific analyzer properties (see Scan my project), the best way is to use Connected mode and set the configuration in the SonarQube (Server, Cloud) or SonarQube Community Build quality profile.

Last updated

Was this helpful?