Sonarqube Phpstorm



SonarQube provides a plugin for IntelliJ (and Eclipse as well) which is a great tool to perform dev-box code analysis before committing or checking-in your changes. It gives the developers a chance to check and make sure they aren’t introducing any new defects or technical debt in the code they have added or modified. Here’s how to set up the plugin and get going.

In this section, we setup our IntelliJ IDEA workspace to integrate with our SonarCloud server so that we can use a centralized quality profile. In this particular video, we are going to cover how to configure SobarLint and SonarQube in IntelliJ IDE.Thanks for watching.

Install SonarQube IntelliJ Plugin

Sonarlint
  • Launch IntelliJ and go to File -> Settings -> Plugins
  • Search for ‘sonarqube’ and install the plugin

Setting up SonarQube plugin

  • In IntelliJ go to File -> Settings -> Other Settings -> SonarQube
  • Add details about the sonar server here. The plugin will use this to download the quality profile/analyzers etc.
  • This plugin executes the analysis in preview mode where no data is pushed to the server.

Sonarqube Ide Plugin

Associate your IntelliJ project with Sonar project

  • Right click on the project in IntelliJ and select 'Associate with SonarQube…'
  • Search for the sonar project and select it

Intellij Sonar

Running the analysis

Sonarlint for intellij

Idea Sonarqube

  • Make your code changes
  • Right click on the project and select Analyze -> Run Inspection by Name…
  • In the search box type 'Sonarqube' and select 'SonarQube Issue' from the result list
  • In the 'Inspection Scope' dialog, select Custom Scope and set its value to Changed Files. This will ensure that the analysis is run on the files modified by you.

Intellij Sonarqube Plugin

  • The plugin will run the preview analysis and display the results in the inspection tab. The inspection shows issues in two files which were modified before the analysis.