Previous Versions Overview - kevin-hinz/sonarlint-docs-migration-render GitHub Wiki

Page Item: Previous Versions

SLUG: previous-versions

HEADING 1

REVIEW CONTENT HERE TO SEE IF IT IS STILL TOP-LEVEL OR MORE INTEGRATED

tabbed

Eclipse

PLACE ECLIPSE CONTENT HERE TO ENTERED INTO THE KONTENT.AI-SPECIFIC ASSET

Installing older versions of SonarLint for Eclipse

For offline installation and older versions see the update site archive at https://binaries.sonarsource.com/SonarLint-for-Eclipse/releases/.

tabbed

IntelliJ

PLACE INTELLIJ CONTENT HERE TO ENTERED INTO THE KONTENT.AI-SPECIFIC ASSET

tabbed

Visual Studio

PLACE VISUAL STUDIO CONTENT HERE TO ENTERED INTO THE KONTENT.AI-SPECIFIC ASSET

Connected Mode

Legacy Connected Mode

Prior to version 4.0 (released May 2018), Connected Mode behaved slightly differently:

  • the appropriate NuGet package for the SonarAnalyzer.CSharp/SonarAnalyzer.VisualBasic analyzers were added to each project
  • the Connected Mode settings were saved in a solution-level folder called SonarQube in a file called SolutionBinding.sqconfig.

In subsequent versions of SonarLint:

  • the analyzer NuGet packages are no longer installed in any project
  • the settings are saved in a solution-level folder called .sonarlint in a file called [solution name].slconfig

Versions Prior to v4.34 only

INFO

WARNING

This page describes the behavior of SonarLint versions 4.34 or older. Javascript analysis is enabled by default version 4.34+.

Overview

Out of the box, SLVS will analyse C#, VB.NET and C/C++. Support for additional languages requires the download of another component, the SonarLint daemon. This simply requires clicking a button in the Tools, Options, SonarLint tab as described below.

The only additional language currently supported is JavaScript, although it is likely this set of supported languages will increase in the future.

Enabling analysis of additional languages

To enable analysis of additional languages, select Tools, Options, SonarLint and click on the "Activate" button then clicking "OK". The SonarLint daemon binaries will be downloaded in the background, with the download progress being shown in the Visual Studio status bar.

Once the download has completed, JavaScript files will be analysed whenever you save them.

Specifying an alternative download location (SLVS v4.11 or later)

By default the additional binaries will be downloaded from the public site https://binaries.sonarsource.com/Distribution/sonarlint-daemon/. If you are working in an environment in which developer machines do not have access to the public internet, you can host the required binaries yourself and set the environment variable SONARLINT_DAEMON_DOWNLOAD_URL to tell SLVS where to find the binaries.

There are few restrictions:

  • the environment variable SONARLINT_DAEMON_DOWNLOAD_URL must be set before VS starts.
  • the URL must be absolute.
  • the daemon zip file must not be renamed i.e. it must in the format sonarlint-daemon-{version}-windows.zip.

Changes to C/C++ analysis in SLVS v4.12

  • Prior to SLVS v4.12 C++ was an additional language so C/C++ analysis would only occur if support for additional languages was enabled. Since v4.12 the C/C++ analysis binaries have been included in the SLVS VSIX so the SonarLint daemon is not required. If you were using SLVS to analyse C/C++ prior to v4.12, you no longer need to have support for additional languages enabled unless you also want JavaScript files to be analysed.

The SonarLint daemon

Most of the Sonar analyzers are written in Java and so need to be run in a Java process. The SonarLint daemon is a Java component that runs in the background and hosts the supported Sonar analyzers. There is no need to have Java installed separately on your development machine - the SonarLint daemon download includes the necessary Java runtime files.

SLVS handles communication with the daemon behind the scenes. Informational messages about the daemon will appear in the SonarLint pane of the Visual Studio Output tool window. Otherwise, the existence of the daemon should be completely transparent to the end user: SLVS will take care of starting and stopping the daemon, passing files for analysis, processing the results and displaying them in the Visual Studio Error List.

The daemon will only be started when you open a file that can be analysed by the daemon, and it will be closed automatically when you close the solution containing the file (note that this was not the case prior to SLVS v4.12; in older versions of SLVS the daemon would start when VS started).

You can use the Task Manager to check whether the daemon is running:

Field Value
Process name java.exe
Process description OpenJDK Platform binary
File location %LOCALAPPDATA%\SonarLint for Visual Studio\sonarlint-daemon-{version}-windows\jre\bin

tabbed

Visual Studio Code

PLACE VISUAL STUDIO CONTENT HERE TO ENTERED INTO THE KONTENT.AI-SPECIFIC ASSET

Connected Mode Setup for previous versions

SonarLint v3.6-v3.7

Starting from v3.6 of SonarLint for VSCode, to set up SonarQube/SonarCloud connections, open a SONARLINT CONNECTED MODE view in VSCode.

Select either Add SonarQube Connection or Add SonarCloud Connection, and complete the fields.

For SonarQube connections, provide your SonarQube Server URL and User Token. For SonarCloud connections, provide your Organization Key and User Token. User Tokens should be generated on the SonarQube/SonarCloud side and pasted into the User Token field.

User Tokens can be generated using these pages:

  • SonarQube - https://<your-sonarqube-url>/account/security/
  • SonarCloud - https://sonarcloud.io/account/security/

Connection Name is a friendly name for your connections. In the case of multiple connections, it also acts as a connectionId.

SonarLint for VSCode v3.6 and above has the option to enable/disable Receive notifications when starting a new connection. Notifications can also be enabled/disabled from the UI while editing the connection setting (see next image below). Action buttons used to edit/delete existing, or create additional connections will be revealed in the UI when hovering over each connection.

Select Save Connection and verify that the new connection was set up successfully in the Connected Mode view.

Action buttons to edit/delete existing, or create additional connections will be revealed when hovering over each connection.

Project Binding v3.6-3.7

Establish your SONARLINT CONNECTED MODE as described above.

Project Bindings can be configured either at the workspace level or in every workspace folder by modifying the settings.json file. Example:

{
    "sonarlint.connectedMode.project": {
        "projectKey": "the-project-key"
    }
}

If you plan to use multiple connections to different SonarQube servers and/or SonarCloud organizations, simply give a unique connectionId to each entry and use them as reference in the binding. Example:

// In project1/.vscode/settings.json
{
    "sonarlint.connectedMode.project": {
        "connectionId": "mySonar",
        "projectKey": "the-project-key-on-sq"
    }
}

// In project2/.vscode/settings.json
{
    "sonarlint.connectedMode.project": {
        "connectionId": "myOrgOnSonarCloud",
        "projectKey": "the-project-key-on-sc"
    }
}

SonarLint Versions 3.5.4 and Lower

Connection details should be configured in the VSCode user settings (user token, SonarQube server URL, or SonarCloud organization). For security reasons, the token should not be stored in SCM with workspace settings (why we suggest configuring in VSCode user settings).

Example for SonarQube:

{
    "sonarlint.connectedMode.connections.sonarqube": [
        { "serverUrl": "https://sonarqube.mycompany.com", "token": "<generated from SonarQube account/security page>" }
    ]
}

Example for SonarCloud:

{
    "sonarlint.connectedMode.connections.sonarcloud": [
        { "organizationKey": "myOrg", "token": "<generated from https://sonarcloud.io/account/security/>" }
    ]
}

Notifications from your project's Quality Gate can be toggled using the disableNotifications field in a server connection definition.

Project Binding v3.5.4 and Lower

SonarLint v3.5.4 and earlier allows bindings either at the workspace level, or at each workspace folder. Example:

{
    "sonarlint.connectedMode.project": {
        "projectKey": "the-project-key"
    }
}

If you plan to use multiple connections, to different SonarQube servers and/or SonarCloud organizations, simply give a unique connectionId to each entry, and use them as reference in the binding. Example:

// In user settings
{
    "sonarlint.connectedMode.connections.sonarqube": [
        { "connectionId": "mySonar", "serverUrl": "https://sonarqube.mycompany.com", "token": "xxx" }
    ]
    "sonarlint.connectedMode.connections.sonarcloud": [
        { "connectionId": "myOrgOnSonarCloud", "organizationKey": "myOrg", "token": "yyy" }
    ]
}

// In project1/.vscode/settings.json
{
    "sonarlint.connectedMode.project": {
        "connectionId": "mySonar",
        "projectKey": "the-project-key-on-sq"
    }
}

// In project2/.vscode/settings.json
{
    "sonarlint.connectedMode.project": {
        "connectionId": "myOrgOnSonarCloud",
        "projectKey": "the-project-key-on-sc"
    }
}