Setup and run Sonar Analysis in Mac

Please download below software in a folder of choice
1. == SonarQube Server
2. == Sonar-Scanner CLI

SonarQube is the central server holding the results of the analysis.

SonarQube Scanner is a tool to performs analysis and send the results to SonarQube.

Prerequisite to run sonar analysis: we need to have Java 8 on mac.

Best way to install java is through homebrew, which is a command line tool for MAC.
if homebrew is not installed, run the following command to install homebrew on mac
>>/usr/bin/ruby -e “$(curl -fsSL"

After homebrew is installed run following command to install java
>>brew cask install java

Two-Step Process to run the Quality analysis.

Step 1: Start the Sonar Qube server

In the first download (Sonar Qube Server), there is a bin folder, which contains three folders for three OS namely Mac, Windows, Linux.. Choose the MAC folder
Mac folder contains, utility file to interact with sonar server.

So our first step is to start the sonar server for this, we run this utility file by the opening terminal in (mac folder)it’s parent folder and execute the following command
`./ start`

the list of available commands can be viewed using the following command
`./ — help`

Step 2: running sonar-scanner cli to perform analysis
2.a: map sonar-scanner to point to sonar-qube server of choice (local in our case)
>for this open
and make sure it has following two lines uncommented # pointed to local sonar server running at port 9000

2.b: Now run the sonar-scanner cli using the following command in the project folder
>>sonar-scanner -Dsonar.projectKey=projectName -Dsonar.sources=.

the above command will run sonar analysis and upload the report to our local sonar server running at port 9000

understanding cli parameters
1. -Dsonar.projectKey = used to identify the project for report uploaded to the sonar server
2. -Dsonar.sources = for telling sonar-scanner which folder to use for running sonar analysis
3. = the location of our sonar server, (this is redundant in the current case since we have already written the property in above)

I love learning