arrow-left

All pages
gitbookPowered by GitBook
1 of 1

Loading...

SonarCloud / SonarLint

hashtag
SonarLint Installation Guide:

Prerequisites:

  • VSCodearrow-up-right with Salesforce Extensionsarrow-up-right installed, configured and connectedarrow-up-right to both Azure DevOps and your ScratchOrg.

  • A SonarCloud account (Free for public projects / ~$10mo for most Salesforce projects) - with a project set up which will be used for the SFDX code analysis, note the projectKey as it will be used in step 14.

Configuration Process:

  1. Install the into VSCode, and restart VSCode

  2. Open your VSCode project related to your ScratchOrg

  3. Visit and log in using the Azure DevOps button.

The following is a sample settings.json file for reference:

Visit your security pagearrow-up-right

  • Under the section titled Generate Tokens, enter vscode and click the Generate button.

  • You will get a new token, copy the token value secure location we will use it later and you will not be able to retrieve it once it is generated.

  • Open Visual Studio Code, and navigate to the setting section

    • On Windows/Linux - File > Preferences > Settings

    • On macOS - Code > Preferences > Settings

  • Select User Settings and Search for SonarLint

  • Ensure that you select User directly under the search box so that you are configuring user settings.

  • Pick any of the settings and click **Edit in settings.json

  • Paste the following into the settings.json file

  • Replace the <<YOUR VSCODE TOKEN GOES HERE>> with the token you created earlier.

  • Replace the <<YOUR COMPANY NAME>> with your organization key

    • You can look up the organization key on the organization key pagearrow-up-right.

  • Replace the <<YOUR PROJECT KEY>> with your project key.

    • You can look up the project key under Administration > Projects Management on your organization's page.

  • You will also likely want to set the Sonarlint > LS: Java Home to the follow the path to your JDK in the same manner you had do to when installing AdoptOpenJavaSDKarrow-up-right

  • Restart VSCode and reopen your VSCode Project related to your ScratchOrg

  • SonarLint Extensionarrow-up-right
    SonarCloudarrow-up-right
    "sonarlint.connectedMode.connections.sonarcloud": [
        {
          "organizationKey": "<<YOUR COMPANY NAME>>",
          "token": "<<YOUR VSCODE TOKEN GOES HERE>>"
        }
      ],
    "sonarlint.connectedMode.project": {
        "projectKey": "<<YOUR PROJECT KEY>>"
      },
    {
        "sonarlint.connectedMode.connections.sonarcloud": [
            {
              "organizationKey": "ecfmg",
              "token": "b33e974....76331859"
            }
          ],
        "sonarlint.connectedMode.project": {
            "projectKey": "sfdc"
          },
        "salesforcedx-vscode-apex.java.home": "/Library/Java/JavaVirtualMachines/adoptopenjdk-11.jdk/Contents/Home",
        "sonarlint.ls.javaHome": "/Library/Java/JavaVirtualMachines/adoptopenjdk-11.jdk/Contents/Home"
    }