Configure SonarLint with IDE (IntelliJ)

Step 1 – Install SonarLint plugin in IDE

  • Go to IntelliJ IDE → Preferences → Plugins 
  • Search for ‘SonarLint‘ plugin under Marketplace
  • Install the plugin by clicking on ‘Install
  • Once plugin is installed successfully, please restart IDE

Step 2 – Configure SonarQube server details

  • Go to IntelliJ IDE → Preferences → Other Settings → SonarLint General Settings → Settings → Click on ‘+’ 
  • In the ‘Server Details‘ window
    • Fill in the Configuration Name (e.g. SonarConfig) and
    • Select ‘SonarQube‘ as the connection type
    • Fill in SonarQube URL 
    • Click Next
  • In the ‘Authentication‘ window, please select required authentication type as ‘Token‘ or ‘Login’ and provide the required details and click on ‘Next‘. 
  • Click on Finish in next window

Step 3 – Configure SonarQube project details for quality profile

  • Go to IntelliJ IDE → Preferences → Other Settings → SonarLint Project Settings → Bind to SonarQube project
  • Enable binding to remote SonarQube server
  • Select configured server from the dropdown under ‘bind to server
  • Search and select the required sonar project configured on remote sonarqube server [Please select project as SonarLint. If doesn’t work, please connect with your lead]
  • Finish and save the settings by clicking OK

Step 4 – Run sonar scan using SonarLint

  • Right click on any file/package/project to sonar scan, choose ‘Analyze with SonarLint‘ to see the sonar report in IDE 🙂