-
Notifications
You must be signed in to change notification settings - Fork 154
Getting Started
The content on this page has moved: https://docs.sonarsource.com/sonarlint/intellij/getting-started/installation/
The SonarLint documentation has moved! Please visit https://docs.sonarsource.com/sonarlint/intellij/ to have a look at the new documentation website. We’ve improved the documentation as a whole, integrated the four SonarLint IDE extension docs together, and moved everything under the sonarsource.com domain to share a home with the SonarQube docs (SonarCloud to come in Q3 of 2023).
These GitHub wikis will no longer be updated after September 1st, 2023 but no worries, we’ll keep them around a while for those running previous versions of SonarLint for IntelliJ.
The easiest way to install the SonarLint plugin is to search the marketplace from the IDE.
Go to File
> Settings
:
Then select the Plugins
> Marketplace
tab:
Then click OK
and restart the IDE to finalize the installation.
You can now enjoy SonarLint!
In case you want to install SonarLint offline, you need to first get access to the plugin zip file.
You can download official versions on the marketplace from this page. Sometimes an ad-hoc version can be built mainly for debugging purposes when a user reports a bug on our community forum.
To install the zip, you can go to File
> Settings
> Plugins
, click on the wheel at the right, then Install Plugin from Disk...
ⓘ NOTE
The content in this section now lives on the new Rules page.
Language | IntelliJ IDEA & Android Studio | CLion | Rider | (DataGrip, Php Storm, PyCharm, RubyMine, and WebStorm) |
---|---|---|---|---|
C# | ✅ | |||
C++ | ✅ | |||
CSS | ✅ | ✅ | ✅ | |
Go | ✅ (GoLand) | |||
HTML | ✅ | ✅ | ✅ | |
Java | ✅ | |||
JavaScript | ✅ | ✅ | ✅ | |
Kotlin | ✅ | ✅ | ||
PHP | ✅ | ✅ | ||
Python | ✅ | ✅ | ||
Ruby | ✅ | ✅ | ||
TypeScript | ✅ | ✅ | ✅ | |
XML | ✅ | ✅ |
In addition, SonarLint for IntelliJ supports the IaC domains for:
Language | IntelliJ IDEA & Android Studio | CLion | Rider | (DataGrip, Php Storm, PyCharm, RubyMine, and WebStorm) |
---|---|---|---|---|
CloudFormation | ✅ | ✅ | ||
Docker | ✅ | ✅ | ||
Kubernetes | ✅ | ✅ | ||
Terraform | ✅ | ✅ |
You can unlock Scala, Swift, and PL/SQL rules when using Connected Mode with SonarQube or SonarCloud.
For more details about languages and new features under consideration for the JetBrains family IDEs, you can refer to the SonarLint roadmap where we list all of our coming soon and newly released features.
Let's analyze a first source file and see what SonarLint can bring.
Copy paste this Java code snippet in a project. It contains a code smell because of duplicated methods:
package org.mycompany;
class MyClass {
private static final String CODE = "XXX";
public String calculateCode() {
doTheThing();
return CODE;
}
public String getName() {
doTheThing();
return CODE;
}
private void doTheThing() {
// do it
}
}
If you open this Java file within the editor, you should see SonarLint reporting the issue by highlighting the text range.
You can hover on the highlight to get a short description of the issue. Clicking on the lightbulb that appears in the left margin will reveal a tooltip containing one or more options, including the option to open a detailed Sonar Rule Description.
Simply select an issue in the SonarLint view or choose SonarLint: Show rule description from the tooltip to open the Rule tab. Here you will find a brief explanation of the rule as well as Noncompliant and Compliant code samples.
SonarLint for IntelliJ supports syntax highlighting. In addition, users are able to visualize a diff view for the non & compliant code sample which should help you fix your issue. Note that diff highlighting is only available for rules descriptions migrated to the new format, and we're progressively migrating all existing rules to the new format.