Static code analyzer now become very common and useful while teams will be working specially using RAD. As to meet close deadlines and sprint dates developers usually get out of the right path and use some narrow tactics to accomplish some task.

I have been facing the same situation in my project in which we couldn’t been able to do peer reviews just to meet close deadlines. So we have configured Sonar just to remove any potential issue which we have missed while development or reviewing the code.

Download latest version of Sonar. e.g 4.3 Stable Release.
Unzip the package using command: unzip
Open to the file which is in folder: /conf/

In that file you can configure sonar settings related to Database and HTTP.
Just to make it easy and time saving we just set the database settings and rest of it will be on default settings.

# Permissions to create tables, indices and triggers must be granted to JDBC user.
# The schema must be created first.
# Comment the following line to deactivate the default embedded database.
#----- MySQL 5.x
# Comment the embedded database and uncomment the following line to use MySQL

In case if you find any issue while connecting to database then change the localhost to ipAddress of your system.

Create a DB which you have mentioned in “sonar.jdbc.url”. For example above we have used “sonar” as our database name.

SonarQube runner:

Download SonarQube runner latest version. It is responsible for analyzing the project and it automatically submit the results in database. Which sonar use for reporting purposes.

Unzip the package using command: unzip sonar-runner
Open the file which is in folder: /conf/

In this file you will find Database and security related settings of sonar qube.

Uncomment any driver of your choice.

#----- MySQL
#----- Global database settings
sonar.jdbc.password={password} file contains information about project and source folders. This file persists at root of your project directory. Below is the content which we can define in that file.

# Required metadata

# Paths to source directories.
# Paths are relative to the file. Replace "\" by "/" on Windows.
# Do not put the "" file in the same directory with the source code.
# (i.e. never set the "sonar.sources" property to ".")

# The value of the property must be the key of the language.

# Encoding of the source code

# Additional parameters

Analyzer Execution:

Move to the bin directory in sonar base folder and execute command.

/ start [in case of any issue try doing that with root permission or with sudo.]

Hit URL localhost:9000 in browser and you will find sonar web page in front of you.

Now move to your project root directory where file is being saved and execute command.


It will start analyzing the project and populate the database so that sonar can use it to display the statistics.

After its completion we can check the results at sonar portal.

Leave a reply

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>