Connected Mode
Connecting SonarQube for IDE to SonarQube Server, SonarQube Cloud, or SonarQube Community Build is the first step in setting up the Sonar Solution, to take advantage of having consistent issues reported on both sides. Setting up connected mode will permit the transmission of information SonarQube for IDE needs, such as URLs and user credentials or file exclusions and marked issues, to communicate with SonarQube (Server, Cloud) or SonarQube Community Build. When binding your local workspace folder to your SonarQube (Server, Cloud) or SonarQube Community Build project(s), SonarQube for IDE will try to match, as much as possible, the same rules and settings as found on the server.
While in connected mode, SonarQube for IDE receives notifications from SonarQube (Server, Cloud) or SonarQube Community Build about your quality gate changes and new issues. Smart notifications can be enabled or disabled from the UI while creating or editing the connection settings.
Benefits
- Analyze more languages and detect more issues by combining SonarQube for IDE’s supported rules with those supported by SonarQube Server and SonarQube Cloud.
- Highlight advanced issues (in the IDE) like injection vulnerabilities, detected by SonarQube (Server, Cloud).
- An issue discovered in SonarQube (Server, Cloud) can be quickly opened in the IDE via a dedicated button.
- Use the same quality profile locally as is defined on the SonarQube Server, SonarQube Cloud or SonarQube Community Build server. You'll also see rules in the same rule mode as defined in SonarQube Server or SonarQube Community Build.
- Apply settings, such as rule selection and file exclusion defined on the SonarQube Server or SonarQube Cloud server to your local analysis.
- Define specific analyzer parameters in SonarQube Server or on SonarQube Cloud, and have those parameters applied locally.
- Automatically suppress issues that are marked as Accepted or False Positive in SonarQube Server or on SonarQube Cloud so that locally reported issues match those found on the server.
When running in connected mode with SonarQube Server 10.4 or newer, Won’t Fix becomes Accept.
- Use the SonarQube for IDE focus on new code feature to concentrate detection of issues only in new code, as you defined in SonarQube Server or on SonarQube Cloud.
- Changes in your SonarQube Server or SonarQube Cloud quality gate will arrive in your IDE when you accept Smart notifications.
Connected mode does not push issues to the server. Rather, its purpose is to configure the IDE so that it uses the same settings, as much as possible, as it is defined on the server.
Free and open-source versions of SonarQube Server and SonarQube Cloud are available to work in connected mode. In SonarQube Cloud, it’s always free to analyze your publicly accessible projects; subscription plans are required only if linking to a private repository.
Prerequisites and supported languages
Having a SonarQube Server project (in an Active version) or a SonarQube Cloud project is required to run SonarQube for IntelliJ in Connected Mode. In addition to the published languages on the Rules and languages page, you can unlock Scala, Swift, and PL/SQL rules when using Connected Mode.
Branch awareness
Branch awareness allows SonarQube for IDE to consider the branch currently checked out in the IDE and synchronize it with the most appropriate branch from the SonarQube (Server, Cloud) or SonarQube Community Build; we call this branch matching.
In Connected Mode, SonarQube for IDE synchronizes some data from the issues found on the server, such as the issue's status and resolution. It is important that SonarQube for IDE knows which branch the user is on at that moment to sync the local analysis with the correct branch analyzed by SonarQube (Server, Cloud) or SonarQube Community Build.
SonarQube for IntelliJ only supports git and the git branch name with regard to branch matching, using the git4idea client shipped by JetBrains. If SonarQube for IDE’s branch awareness algorithm fails to detect a best match, injection vulnerabilities and issue suppressions will be pulled from the main branch by default.
Checking which branches are analyzed on the server
In SonarQube Server, open the highlighted drop-down list shown below (as it looks in SonarQube Server) for a list of analyzed branches and pull requests.
To analyze branches other than master
|main
, please check the SonarQube Server or SonarQube Cloud documentation about branch analysis.
How SonarLint selects which branch to sync
SonarLint deploys these three methods to choose which branch (in SonarQube (Server, Cloud)) to sync with the local analysis.
Exact match
Branches with the same name are considered the same branch. If the branch that is currently checked out locally is analyzed on the server, SonarLint will pick this branch for synchronization.
Closest branch
SonarQube for IDE will consider all local branches that also exist on the server. For each branch, SonarQube for IDE will compute the distance between the current HEAD
and the branch by the count of commits. The closest branch will be kept. In case the number of commits is the same for two or more branches and the main branch is among them, it will be preferred; otherwise, the tie will be broken with a random choice (from the list of equidistance branches).
Default to main branch
All other cases will default to the branch marked as "main" on the server. For example, if there is an error in reading the branch, or if there is no Git repo, SonarQube for IDE will default to the main branch.
Long and short-lived branches
When using Connected Mode with SonarQube Cloud, issues on short-lived branches are not synchronized. When an issue is marked in SonarQube Cloud accepted or false positive on a short-lived branch, SonarQube for IDE will still show that issue in the IDE.
SonarQube Server does not distinguish between long- and short-lived branches therefore, all issue resolutions are recognized.
Connection setup
SonarQube for IntelliJ provides a connection wizard to help you set up Connected Mode with SonarQube (Server, Cloud). Please see the Connected Mode setup page for detailed instructions to set up Connected Mode and bind your project.
Sharing your setup
From version 10.5, you can share a setup configuration file with your team, simplifying the process.
One team member must step through the first-time setup process, then export and commit the binding configuration to the repository. Any team member running SonarQube for IDE will find the binding details inside of the project’s source folder and automatically receive a notification to bind the project.
Please see the Connected Mode setup page for detailed instructions.
Troubleshooting Connected Mode
See the Troubleshooting page for details to look at when your SonarQube for IDE analysis does not match what you see in SonarQube (Server, Cloud).
SonarQube for IDE-SonarQube Server version support policy
SonarQube for IDE enables users to establish a connection to the latest SonarQube Server version and to the latest LTA (Long-Term Active) version. When a new LTA version is released, we still enable connecting SonarQube for IDE to the previous LTA version for a certain period of time (currently 9 months after the latest LTA release) to allow enough time for organizations to upgrade their SonarQube Server version.
For more information about long-term support of SonarQube Server, 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 (Server, Cloud) and SonarQube Community Build 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 (Server, Cloud) and SonarQube Community Build 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 Server, SonarQube Cloud, or SonarQube Community Build documentation for details about using quality gates in your project)
- a SonarQube (Server, Cloud) and SonarQube Community Build analysis raises new issues that you've introduced in a project open in your IDE
You can activate or deactivate smart notifications in SonarQube for IDE on the IDE side for a server-by-server basis.
Sonar Smart Notifications are available in all editions of SonarQube (Server, Cloud) and SonarQube Community Build.
Was this page helpful?