Install Free
IntelliJ | Getting started | Installation

Installation

On this page

For the most part, SonarLint can be installed directly from your IDE's Marketplace. Offline installations are also possible and previous versions are always available if needed.

Instructions

Installation is usually completed via the IDE, directly from the JetBrains Marketplace. In IntelliJ, go to Settings > Plugins; search for sonarlint in the Marketplace tab. Select Install. When complete, you must select Restart IDE and confirm the Restart to activate the new plugin.

If SonarLint does not appear in the Marketplace when searching from within the IDE, it means that your IDE is not supported.

First taste of SonarLint

Now that you have SonarLint installed, open or create a new project containing source files in a programming language SonarLint can analyze out of the box. See the Rules page for languages that work with your IDE.

Then check out the Investigating issues page for details about how to recognize issues found in your code.

JetBrains flavor: IntelliJ IDEA

Language: Java

import java.util.ArrayList;
import java.util.List;

public class Main {
  public static void main(String[] args) {
    List<String> texts = new ArrayList<String>();
    if (texts != null) {
      texts.add("Hello World!");
    }
  }
}

This code sample should raise two issues:

  1. Remove this expression which always evaluates to “true”
    • It has three secondary locations explaining the flows
  2. Replace the type specification in this constructor call with the diamond operator (“<>”)
    • It has a quick fix

JetBrains flavor: CLion

Language: C++

#include <string>

typedef int Integer;

size_t get_size(std::string& s) {
    return s.size();
}

This code sample should raise two issues:

  1. “using” is preferred to “typedef” for type aliasing
    • It has a quick-fix
  2. Make the type of this parameter a reference-to-const

CLion offers multiple ways of setting up a C++ project using different build tools and allows the use of different compilers. Note that you may need to install dependencies on your machine beforehand.

JetBrains flavor: Rider

Language: C#

    public class Math {
        int Pow(int num, int exponent)
        {
            return num * Pow(num, exponent - 1);
        }
    }

This code sample should raise one issue:

  1. The method is in an indefinite loop

JetBrains flavor: WebStorm

Language: TypeScript

const a = NaN;

if (a === NaN) {
    console.log("a is not a number");
}

This code sample should raise one issue:

  1. The code inside the condition is dead code

Rider

There are specific requirements for Rider which are documented inside the SonarLint in Rider collapsible on the Scan my project page.


Was this page helpful?

© 2008-2024 SonarSource SA. All rights reserved. SONAR, SONARSOURCE, SONARQUBE, and CLEAN AS YOU CODE are trademarks of SonarSource SA.

Creative Commons License