Install Free
IntelliJ | Team features | Connected Mode setup

Connected Mode

On this page

Connection setup

SonarLint for IntelliJ provides a connection wizard to help you set up Connected Mode with SonarQube or SonarCloud:

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

1. Open your IntelliJ Settings..., find the Tools > SonarLint entry, and select + to open the connection wizard. 

Choose SonarQube and add server details to set up your connection with SonarLint.

2. Enter a name for this connection. When you select SonarQube, you will need to enter the server URL before selecting Next to proceed. The default URL is http://localhost:9000, but your URL might differ.

3. On the window, choose your preferred authentication method:

  • Token: generate a user token in your SonarQube instance. This is the preferred way to avoid the compromise of your username & password. In SonarQube, go to https://<your-sonarqube-url>/account/security/ to generate a new user token.
  • Username + Password: this method can be used for a SonarQube connection only and is deprecated in SonarLint for IntelliJ 10.6. It lets SonarLint use your credentials directly but is not the recommended method due to potential security risks. The option will be removed in a future version of SonarLint.

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 SonarQube connection.

Create a new SonarCloud Connection

1. Open your IntelliJ Settings..., find the Tools > SonarLint entry, and select + to open the connection wizard. 

Choose SonarCloud and add server details to set up your connection with SonarLint.

2. Enter a Connection Name for this connection and select SonarCloud. Connection Name is a friendly name for your connections.

3. You will be prompted to add a user Token generated by SonarCloud. If you don't already have a token, clicking the Create token button will open the https://sonarcloud.io/account/security page in your default browser where you can select Generate Token in SonarCloud. 

4. Select the SonarCloud Organization that you want to connect to (you can also select any public organization). 

5. SonarCloud can push notifications to developers. You can decide whether or not to subscribe in the SonarCloud UI.

6. Validate the connection creation by selecting Finish at the end of the wizard.

7. Save the connection in global settings by clicking OK.

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 Connected Mode is established, you must bind your IDE project to a SonarQube or SonarCloud project.

Select Bind project to SonarQube / SonarCloud to start the next step in setting up Connected Mode.

1. Open IntelliJ > Settings... and find the Tools > SonarLint > Project Settings entry (shown above).

2. Select Bind project to SonarQube/SonarCloud and choose the previously created connection name in the dropdown list

3. Enter the project key as it is configured on SonarQube/SonarCloud. You can also select it by using Search in list...:

You can enter your Project key directly into the field, or use the search function to find it in a list of projects in your Organization.

You will receive a notification that the binding is successful. 

Open the Save and share your setup collapsible below for the complete instructions.

Save and share your setup: Recommended for teams

Reuse the binding configuration

Export the binding configuration

From an open project already bound to SonarQube or SonarCloud,

  • Open the Project Settings from the SonarLint view by clicking on the toolbox icon (-) or navigate to IntelliJ > Settings > Tools > SonarLint > Project Settings to open the Bind to SonarCloud / SonarQube tab.
  • Select the Bind project to SonarCloud / SonarQube checkbox, then select Share configuration… to start the process.

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 IntelliJ, SonarLint will check for a shared binding configuration file and notify users.

  • Select Use configuration in the notification to open the connection wizard. SonarLint will pre-populate the connection wizard with the binding configuration and you will be asked to verify the server connection.

If no connection exists, Sonarlint will ask you to create a new connection. Users must provide their own User Token in the Connection Mode setup wizard; 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 setup exists, users are asked only to bind the project using the shared binding configuration.

Bind configurations for hierarchical directories

Some projects may contain multiple shared configuration files. For example, C# projects require a configuration file for each solution, which may be stored in different locations in your directory depending on the SonarLint IDE used to create the shared configuration files.

When you open projects at the root level, SonarLint can find all of the configurations. In contrast, if you open a solution folder in Rider for example, SonarLint will only see the configuration files within the solution.

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. 

Override binding for modules

In IntelliJ additional modules can be imported into a project, e.g. via the 'Project Structure' menu. This is often used for example to group together the back-end and the front-end parts of an application into the same project. As those components might be analyzed separately, SonarLint lets users bind modules to different projects.

1. In the IntelliJ settings, find the Tools > SonarLint > Project Settings entry. Alternatively, you can select the Configure SonarLint tool icon from any of the SonarLint view windows to access the Project Settings menu.

2. Make sure a binding is configured at the project level (see the previous section). Note: this will be the default binding for all modules that have no overridden binding.

3. In the 'Override binding per module' section, click on the + sign and choose the module.

SonarLint gives you the option to override your binding module, if you want.

Troubleshooting Connected Mode

See the Troubleshooting page for details to look at when your SonarLint analysis does not match what you see in SonarQube or SonarCloud.

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).

Notifications

Connected Mode allows SonarQube to send smart alerts to individuals or teams as soon as something appears on the server that something failed, when new issues are discovered or when the Sonar Quality Profile is updated, for example. With everyone in the loop, issues can be addressed promptly, improving the overall software quality and delivery. The notification will include a link to call back to SonarQube or SonarCloud where you can learn more about the issues that were introduced. 

You'll receive smart notifications in your IDE when:

  • the quality gate status of a project open in your IDE changes (see the SonarQube or SonarCloud documentation for details about using quality gates in your project)
  • a SonarQube or SonarCloud analysis raises new issues that you've introduced in a project open in your IDE

You can activate or deactivate smart notifications in SonarLint on the IDE side on a server-by-server basis.

Sonar Smart Notifications are available in all editions of SonarQube and SonarCloud.

More on how to manage Smart Notifications in SonarLint for IntelliJ will be coming soon...

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?

© 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