These following steps will help you run a SonarQube analysis in one of your local projects, and then see the report of the issues found.
First off, you’ll need to configure the SonarQube scanner as an enviroment variable
SONAR_RUNNER_HOME=home/sonar-scanner-2.5.1
PATH=$PATH:$SONAR_RUNNER_HOME/bin
Next, you are going to need to add the Apex plugin jar file (apex-plugin.jar) to the plugins of Sonarqube, in the following subfolder “/sonarqube/extensions/plugins/”
In the folder where you installed SonarQube, you need to go to the sub-folder bin
and then to the sub-folder corresponding to your OS.
Once inside, run ./sonar.sh console
to start the SonarQube server.
Create a sonar-project.properties file at the root of your project
sonar.projectKey=my:project
sonar.projectName=My project
sonar.projectVersion=1.0
sonar.language=apex
sonar.sources=.
sonar.projectKey: must be unique in a given SonarQube instance
sonar.projectName: this is the name displayed in the SonarQube UI
sonar.language: specifies the language for analysis
sonar.sources: this “dot” indicates to sonnar scanner to scan all files from the current level of directories, this is, all files that have an extension “.cls”. This extension is defined by plugin scanner.
Run ‘sonar-runner’ command from the project root dir.
Follow the link provided at the end of the analysis to browse your project’s quality in SonarQube UI.