SonarLint offers a fully-integrated user experience in IntelliJ IDEA. After installing the plugin you'll get on the fly analysis of your code and a new action called 'Analyze with SonarLint'.

SonarLint is free, open source, and available in the Jetbrains Plugin Repository. Note that it requires Java 8 to run.

SonarLint in IntelliJ IDEA

News

  • September 7, 2016 - Bugfix version 2.3.2 released, fixing "disable automatic analysis" configuration not persisted, and classpath issue.
  • August 26, 2016 - Bugfix version 2.3.1 released, fixing an analysis configuration problem introduced in 2.3 and performance issues. It also includes the new embedded analyzers Java v4.2 and Javascript v2.15.
  • August 5, 2016 - version 2.3 released, introducing the support of exclusions in connected mode. It also contains numerous bug fixes. Starting from this version, Java 8 is required to run SonarLint.
  • June 3, 2016 - version 2.2 extends support of connected mode to SonarQube 4.5.4+. Some SonarSource commercial languages are also supported.
  • May 13, 2016 - v2.1 contains a bug that prevents it from starting in PHPStorm. A bugfix version version 2.1.1 was released to fix the problem.
  • May 12, 2016 - version 2.1 of SonarLint for IntelliJ IDEA is released. It contains numerous improvements and bug fixes. The embedded analyzers were upgraded - Java v3.13.1 and Javascript v2.12.
  • April 29, 2016 - Another bug fix version released: version 2.0.2.
  • April 20, 2016 - Important bug fixes released with version 2.0.1.
  • April 15, 2016 - Version 2.0 of SonarLint for IntelliJ IDEA is released. Connected mode has arrived! It's now possible to connect to a SonarQube server to use the rules of a specific SonarQube project.
  • March 4, 2016 - Version 1.5 of SonarLint for IntelliJ IDEA is released. Issues panel shows the age of the issues since Intellij was restarted, sorting them by the most recent first.
  • February 18, 2016 - Version 1.4 of SonarLint for IntelliJ IDEA is released. The plugin is now fully standalone: there is no more dependency on http://update.sonarlint.org. We removed the quick fix // NOSONAR that was too controversial. Java analyzer is updated to its latest version (3.10). Some rules were added on pom.xml files. Several bug fixes are included too.
  • January 29, 2016 - Version 1.3 of SonarLint for IntelliJ IDEA is released. The main new feature is a view with the issues in SonarLint's tool window. There are also other UI improvements.
  • January 15, 2016 - We have updated Java and JavaScript analyzers to their latest version (Java 3.9 and JavaScript 2.10). Use Help -> Update SonarLint analyzers menu to get them.
  • January 13, 2016 - Version 1.2 of SonarLint for IntelliJ IDEA is released. On the fly analysis is back and enabled by default. Highlighting of issues is now configurable by severity (including error stripes) and we have now a "NO SONAR" quick fix.
  • December 16, 2015 - Version 1.1 of SonarLint for IntelliJ IDEA is released. It features more precise issue locations, improved console and better adaption of markers to code changes. The analysis is now triggered manually with actions, available directly through key bindings and the editor menu.
  • December 7, 2015 - We published updated versions of Java, JavaScript and PHP analyzers. Few more rules and many improvements to existing ones. Use Help -> Update SonarLint menu to get new analyzers.
  • October 9, 2015 - Today we released Version 1.0 of SonarLint for IntelliJ IDEA. Java, JavaScript and PHP are supported.

Rules

Connected Mode

You can bind IntelliJ projects to a SonarQube project (supporting SonarQube servers 4.5.4+). This operation will make SonarLint use the analyzers, quality profiles and settings defined on your SonarQube server. This is a convenient way of customizing the rules used by SonarLint.

First step is to configure the SonarQube server:

  • In the SonarLint Global Settings, click in the add icon;
  • Configure the server. For servers 5.4+, it is recommended to use authentication token, which can be created from your profile page in SonarQube;

After adding a new SonarQube server configuration, a local update will immediately be triggered. To manually trigger an update of a local configuration at any later time (for example, if the remote SonarQube configuration changes), click in the "Update binding" button.

Once this initial update is done, you can bind the IntelliJ project to a SonarQube project in the SonarLint Project Settings:

  • Enable binding by selecting the check box;
  • Select the SonarQube server to be used. A warning will be displayed if the local data is not updated;
  • Select the SonarQube project. SonarLint will use the quality profile and settings from this project;

That's it, you can now code and see SonarLint reporting issues based on the remote SonarQube configuration.

Frequently Asked Questions

  • How to enable SonarLint? - SonarLint is enabled by default.
  • Which languages are supported? - Java, JavaScript, PHP. With the Connected Mode, it adds: ABAP, COBOL, PL/SQL, Python, Swift.
  • How can I connect SonarLint to my SonarQube server? - Check the Connected Mode section. This allows to configure rules and settings, but there is no tracking of issues yet.
  • Where can I find logs of analysis or about the configuration that SonarLint is using? - In the 'logs' tab of SonarLint tool window. You can configure it to display verbose and/or analysis logs.
  • In Connected Mode, will all plugins installed on SonarQube be executed in SonarLint? - SonarLint supports only the SonarSource Analyzers. We plan to quickly add support for custom rules extending the Java, JavaScript and PHP Analyzers. We don't plan to support plugins running third-party analyzers in order to keep SonarLint as fast as possible.
  • How to start SonarLint analysis? - By default, SonarLint analysis are triggered automatically when working on the code (this behaviour can be disabled in the configuration). It can also be launched manually with the action "Analyze this file with SonarLint" (Control+Shift+A). This action has a configurable key binding (Control + Shift + S by default) and is also available in the SonarLint console and editor popup menu.
  • How to configure rules? - Check the Connected Mode section. When not connected to a SonarQube server, these are the rules used by SonarLint.
  • Can I change the highlighting of issues? - Yes, in Settings -> Editor -> Colors & Fonts -> SonarLint. By default, the highlighting of issues matches the standard warnings and errors, but it can be customized by severity, including the error stripe on the right bar.
  • How to exclude files from the analysis? - SonarLint analysis will run on every source file but only Java, JavaScript and PHP files are processed. Advanced users can configure some properties (File -> Settings -> SonarLint) like sonar.exclusions.
  • How to update SonarLint? - SonarLint IntelliJ Plugin can be updated like any other IntelliJ plugin. Updates are done regularly, which include sometimes new analyzers with improved rule engines.

Contribute

SonarLint for IntelliJ IDEA is open source under the LGPL v3 license. You can fork us on GitHub, and submit Pull Requests. Feel free to fix bugs or to implement new features.

Feedback

The preferred way to discuss about SonarLint is by posting on the SonarLint Google Group. We are also constantly monitoring questions posted to StackOverflow. For faster answers mark your StackOverflow questions with [SonarLint] and [IntelliJ] tags.