In this we will analyse one sample project with SonarQube and SonarQube scanner. Make sure your configuration of SonarQube server and SonarQube Scanner is done. If not, refer SonarQube and SonarQube Scanner installation guide.
I am using one example project which I have forked on my github account. It is a simple MEAN app.For analysing projects with SonarQube you must have all necessary language plugins installed on your server.
- Login as Administrator in SonarQube Server
- Click on administration tab
- Click on System it will give dropdown menu.
- Click on Update Center
- You can see all installed and available plugins.
- According to your project install those plugins.
- Now your server is capable of analysing projects with those installed plugins.
- Sonar-runner (now sonar-scanner) is default launcher to anlayse project with SonarQube.
- Create Configuration file in root direcctory of project.
- For sample we are using one example project from our github.
- Configuration file consist ,
# must be unique in a given SonarQube instance sonar.projectKey=my:project # this is the name and version displayed in the SonarQube UI. Was mandatory prior to SonarQube 6.1. sonar.projectName=My project sonar.projectVersion=1.0 # Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows. # Since SonarQube 4.2, this property is optional if sonar.modules is set. # If not set, SonarQube starts looking for source code from the directory containing # the sonar-project.properties file. sonar.sources=. # Encoding of the source code. Default is default system encoding #sonar.sourceEncoding=UTF-8
- For our sample project , you can clone project from here
- In root directory create sonar-project.properties ,
#This is sonar properties file. Sonar-runner will understand different parameters for analysis with this file #You will get complete parameters list at http://docs.sonarqube.org/display/SONAR/Analysis+Parameters #Parameters start #Sonar host url - used for making connection with server sonar.host.url = http://localhost:9000/sonar #Project related mandotary parameters sonar.projectKey = LoopbackAngularMaster sonar.projectName = LoopbackDemo sonar.projectVersion = 1.0 #Comma-separated paths to directories containing source files. sonar.sources = client , common , server #Project configuration Parameters sonar.projectDescription = Its an example angular app forked from github. #Set the source file encoding.Encoding of source files. Example of values: UTF-8, MacRoman, Shift_JIS. sonar.sourceEncoding = UTF-8 #Set analysis language #Set the language of the source code to analyze. Browse the http://docs.sonarqube.org/display/PLUG/Plugin+Library page to get the list of all available languages. #If not set, a multi-language analysis will be triggered. #sonar.language = Javascript , CSS #Commented beacuse We want to set multi language analysis
- Run sonar-runner or sonar-scanner
$ sonar-scanner