SFDX Unlocked Packages Guide
  • Project Overview
  • Lifecycle Guidance
    • Development Models
    • Team Sprint Collaboration
    • Git Strategy
    • Development Guidance
    • Testing Guidance
    • Agile/DevOps shift-left testing
    • Code Promotion
  • Salesforce DX & CI/CD
    • Quality Hooks
  • Supporting Infrastructure & Environments
    • Environment Types
      • Scratch Org Guidance
      • Sandbox Guidance
      • Handling Secure Data
  • Opinionated Guide
    • Introduction
  • Developer Resources
    • SFDX Package Development
      • Introduction
      • Creating Unlocked Packages
        • Package Errors
      • Project Structure
    • Pipeline Introduction
    • Developer Machine Setup
      • VS Code Configuration
      • Creating the SFDX Project
    • Extras
      • SonarCloud / SonarLint
      • Code Review Checklist
      • Additional External Resources
    • Untitled
  • Running the Org
    • Team Responsibilites
    • Onboarding Resources
  • Journey to Unlocked Packages
    • Introduction
    • Getting Ready for Source Driven Development
    • Moving from Unmanaged to Unlocked
    • Unlocked Guidance
  • Test Automation
    • Manage Test Data
    • UI Test Automation - POM Framework
    • Agile/DevOps Shift-left Testing
    • Selenium Extent Reports - Dotnet Core
    • Dotnet Core Selenium Tests on Azure-devops-pipeline
Powered by GitBook
On this page

Was this helpful?

Export as PDF
  1. Developer Resources
  2. Extras

SonarCloud / SonarLint

PreviousExtrasNextCode Review Checklist

Last updated 5 years ago

Was this helpful?

SonarLint Installation Guide:

Prerequisites:

  • with installed, 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.

  4. Visit

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

  6. 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.

  7. Open Visual Studio Code, and navigate to the setting section

    • On Windows/Linux - File > Preferences > Settings

    • On macOS - Code > Preferences > Settings

  8. Select User Settings and Search for SonarLint

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

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

  11. Paste the following into the settings.json file

    "sonarlint.connectedMode.connections.sonarcloud": [
        {
          "organizationKey": "<<YOUR COMPANY NAME>>",
          "token": "<<YOUR VSCODE TOKEN GOES HERE>>"
        }
      ],
    "sonarlint.connectedMode.project": {
        "projectKey": "<<YOUR PROJECT KEY>>"
      },
  12. Replace the <<YOUR VSCODE TOKEN GOES HERE>> with the token you created earlier.

  13. Replace the <<YOUR COMPANY NAME>> with your organization key

    • You can look up the organization key on the .

  14. 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.

  15. 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

  16. Restart VSCode and reopen your VSCode Project related to your ScratchOrg

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

{
    "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"
}

VSCode
Salesforce Extensions
configured and connected
SonarLint Extension
SonarCloud
your security page
organization key page
AdoptOpenJavaSDK