VS Code | Team features | Connected Mode setup

On this page

Connected Mode

Connection setup

SonarLint for VS Code version 3.8 and above provides a connection wizard to help you set up Connected Mode. To set up a SonarQube or SonarCloud connection, navigate to the SONARLINT > CONNECTED MODE view container from the Activity Bar.

Select either Add SonarQube Connection or Add SonarCloud Connection, and complete the fields.

Automatic setup

SonarQube 10.4+ offers the easiest way to set up Connected Mode: simply use the Open in IDE feature from SonarQube. You must trust the SonarQube server to store a token for the connection, and it's best if you already have the project open in your IDE. 

Check the Troubleshooting article if something doesn’t work right or follow the instructions below to manually create a SonarQube connection.

Create a new SonarQube Connection

Add the SonarQube server details to set up your connection with SonarLint.

For SonarQube connections, provide your SonarQube Server URL and User Token, and specify a Connection Name

  • Server URL: enter your server URL here, by default, it is http://localhost:9000
  • User Tokens are generated by your SonarQube instance. Note that a user token is the only token type that works with Connected Mode. In SonarQube, go to https://<your-sonarqube-url>/account/security/ to generate a new user token.
  • Connection Name is a friendly name for your connections. In the case of multiple connections, it also acts as a connectionId.
  • Notifications can be enabled or disabled here, or you can return to the Edit SonarQube Connection page at any time by clicking on the pencil in the SONARLINT > CONNECTED MODE view in the Side Bar.

Finally, select Save Connection then check out the CONNECTED MODE view in the Side Bar to verify that the set up was successful.

The final steps involve binding your local project to the project on the server.

Create a new SonarCloud Connection

Add the SonarCloud server details to set up your connection with SonarLint.

For SonarCloud connections, provide your Organization Key and User Token, and specify a Connection Name.  

  • Your Organization Key can be found by going to your Account > Organizations page: https://sonarcloud.io/account/organizations. Keys for third party organizations can be found by going to the project's information page.
  • User Tokens are generated on SonarCloud. Navigate to https://sonarcloud.io/account/security/, give your new token a name, and select Generate Token.
  • Connection Name is a friendly name for your connections. In the case of multiple connections, it also acts as a connectionId.
  • Notifications can be enabled or disabled here, or you can return to the Edit SonarCloud Connection tab at any time by clicking on the pencil in the SONARLINT > CONNECTED MODE view in the Side Bar.

Finally, select Save Connection then check out the CONNECTED MODE view in the Side Bar to verify that the setup was successful.

The final steps involve binding your local project to the project on the server.

Project Binding

SonarLint keeps server-side data in local storage. If you change something on the server such as the quality profile, SonarLint will automatically attempt to synchronize with configured servers at startup and once every hour and will do its best to synchronize with the most appropriate branch from the server. 

SonarLint keeps server-side data in local storage and uses a binding process to synchronize with configured servers at startup; one example would be the quality profile defined by your Organization in SonarQube. SonarLint will automatically attempt a binding update once every hour and will do its best to synchronize with the most appropriate branch from the server. 

How to bind a project

Once a connection is established, SonarLint for VSCode tries to automatically detect a remote SonarQube or SonarCloud project to bind with the locally opened workspace folder. If the locally opened folder contains a sonar-project.properties or a .sonarcloud.properties file, SonarLint will try to configure the binding with the remote project defined in that configuration file.

If no remote match is found, you will be prompted to configure binding manually as we describe below.

To manually configure a project binding, open the CONNECTED MODE view and select Add Project Binding for the desired connection.

Select the + icon to add a new SonarQube or SonarCloud project binding.
Select the + icon to add a new SonarQube or SonarCloud project binding.

If your open workspace contains multiple folders, you will be prompted to choose a specific folder.

Select the branch you want to bind to your SonarLint instance.

After selecting the folder, choose the remote SonarQube/SonarCloud project you would like to bind.

Select the project on the server to bind with your local folder.
Select the project on the server to bind with your local folder.

Select the desired project and enjoy Connected Mode! You can also edit or delete bindings from the CONNECTED MODE view.

Select the pencil to edit your SonarQube or SonarCloud binding.
Select the pencil to edit your SonarQube or SonarCloud binding.

Action buttons in the UI used to edit/delete existing or create additional connections will be revealed when hovering over each connection.

Update a binding

Simply mouseover the SonarLint CONNECTED MODE view and select the update icon: ↻

Additionally, you can trigger an update of the local storage using the SonarLint: Update all project bindings to SonarQube/SonarCloud command on the Command Palette.

SonarLint-SonarQube version support policy

SonarLint enables users to establish a connection to the latest SonarQube version and to the latest LTS version. When a new LTS version is released (approximately every 18 months), we still enable connecting SonarLint to the previous LTS version for a certain period of time (currently 12 months after the latest LTS release) to allow enough time for organizations to upgrade their SonarQube version. 

For more information about long-term support of SonarQube, check out our page describing "what is an LTS". And, to review IDE-specific requirements, please check the respective pages of the documentation as listed in the next paragraph.

⚠️ The 8.9LTS reached its support expiration date (in November ’23).

Learn more

Check out the main Connected Mode page to learn more about the benefits of using Connected Mode, information about SonarLint's branch matching strategy, and how to activate and deactivate your Sonar Smart Notifications in the IDE.

© 2008-2024 SonarSource SA. All rights reserved. SONAR, SONARSOURCE, SONARLINT, SONARQUBE, SONARCLOUD, and CLEAN AS YOU CODE are trademarks of SonarSource SA.

Creative Commons License