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
From the SonarLint > CONNECTED MODE panel in the VS Code Activity bar, select Add SonarQube Connection. If you have an existing SonarQube or SonarCloud connection, click on the three dots (...) to select either Connect to SonarCloud or Connect to SonarQube.
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.
User tokens are required when setting up Connected Mode between SonarQube and SonarLint. Note that binding will not function properly if SonarQube project tokens or global tokens are used during the setup process.
The final steps involve binding your local project to the project on the server.
Automatic setup
SonarCloud offers the easiest way to set up Connected Mode: simply use the Open in IDE feature from SonarCloud. You must trust the SonarCloud 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 SonarCloud connection.
Create a new SonarCloud Connection
From the SonarLint > CONNECTED MODE panel in the VS Code Activity bar, select Add SonarCloud Connection. If you have an existing SonarQube or SonarCloud connection, click on the three dots (...) to select either Connect to SonarCloud or Connect to SonarQube.
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.
First-time connection setup for shared binding
One team member must step through the first-time setup process, then export and commit the binding configuration to the repository. Any team member who opens the project while running SonarLint will automatically receive a notification to bind the project. Each team member must use their own project credentials and SonarLint will use the binding details found in the configuration file to complete the connection.
To begin, one person from the team must follow the steps outlined in Using the connection wizard and Configure your binding, then follow the Save and share your setup instructions below to save the project configuration for the rest of the team.
Using the connection wizard
Connected Mode setup
Follow the Connection setup instructions above for your SonarQube or SonarCloud connection.
Configure your binding
Bind your 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 ask you to Configure Binding.
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.
If your open workspace contains multiple folders, you will be prompted to choose a specific folder.
After selecting the folder, choose the remote SonarQube or SonarCloud project you would like to bind.
Select the desired project and enjoy Connected Mode! You can also edit or delete bindings from the CONNECTED MODE view.
Action buttons in the UI used to edit/delete existing or create additional connections will be revealed when hovering over each connection.
After clicking Save Connection, you will receive a "Success!" notice that the binding is successful.
To Save and share your setup, open collapsible below for the complete instructions.
Save and share your setup: Recommended for teams
Reuse the binding configuration
Export the binding configuration
Open the CONNECTED MODE view and reveal the connection and binding you want to share. Then, click the arrow () to open the Share Connected Mode Configuration action.
A confirmation window will pop up, asking you to verify the process. Once confirmed, a .json file containing the SonarQube URI and Project Key or SonarCloud Organization and Project Key will be added to the .sonarlint folder in your project.
Share the binding configuration
Commit the file you just created in the working directory; your teammates should have access to the binding configuration once your commit becomes part of the repository.
Because your Project’s identifying information is saved in a location under source control, it will be available to anyone with access to the project repo. Each team member is still required to have their own SonarQube or SonarCloud credentials; these are managed in SonarQube and SonarCloud, respectively.
Bind using shared configuration
When opening a new project in VS Code, SonarLint will check for a shared binding configuration file and notify users.
- Select Use Configuration to bind your local project to the matching remote project as specified in the configuration file.
- Select Not now to dismiss the suggestion.
- If you select Don’t Ask Again, SonarLint will no longer notify you when a shared binding configuration file is found in your project and you must manually bind your projects.
If no connection exists, Sonarlint will ask to create a new connection. Users must provide their own User Token in the connection setup webview panel; selecting the Generate Token button will open SonarQube or SonarCloud to step through this process and populate the setup form with your new token.
If a matching connection already exists, users are asked only to bind the project using the shared binding configuration.
When finished, select Save Connection And Bind Project to complete the process.
Multiple configurations
When multiple configurations are available, for example, in .NET projects where there is a configuration for each .NET solution, SonarLint will prompt the user to Use Configuration, and then make the user choose which configuration to apply.
Select Use Configuration, then pick the project you want to bind from the VS Code Command Palette.
Sharing configurations between different IDEs
SonarLint extensions are available for IntelliJ (and other Jet Brains IDEs), Visual Studio, VS Code, and Eclipse. Although the information stored in the shared configuration file is the same, each extension might export the JSON file to a slightly different location depending on IDE and project type. This may cause friction when opening a configuration in an IDE other than the IDE that created it.
If SonarLint does not send you a notification to accept a shared configuration, please check first if you have opened your project’s root. If SonarLint still does not suggest a matching configuration, you must configure binding manually. Please see the Configure your binding collapsible above for instructions.
Project binding
SonarLint keeps server-side data in local storage and synchronizes with configured servers at startup; one example would be the quality profile defined by your SonarCloud Organization.
A binding update will automatically be attempted once every hour or after an IDE restart and SonarLint will do its best to synchronize with the most appropriate branch from the server.
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 LTA (Long-Term Active) version. When a new LTA version is released (approximately every 18 to 24 months), we still enable connecting SonarLint to the previous LTA version for a certain period of time (currently 12 months after the latest LTA 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 an LTA is" and, to review IDE-specific requirements, please check the respective pages of the documentation as listed in the next paragraph.
⚠️ The 8.9LTA 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.
Was this page helpful?