What Is sonarQube and How to integrate it with maven project

Posted By : Rahul Chauhan | 20-Dec-2018

What Is soanrQube and How to integrate it with maven project?


Sonar Qube is a tool for analyzing the real-time code analysis it is developed by sonar source in January 2008. It provide support to 20+ languages like java, python,c/c++, .net, PHP etc. Sonarqube is a tool which helps the developer to improve their code quality. SonarQube doesn't just show you what's wrong. It also provides quality-management tools to actively help you put it right. SonarQube provides the capability to check the health of an application and also to highlight issues newly introduced.SonarQube addresses not just find bugs but also coding rules, test coverage, duplications, API documentation, architecture, and complexity, providing all these details in a dashboard. It gives you a moment-in-time snapshot of your code quality today, as well as trends of lagging and leading quality indicators. SonarQube not only addresses core developers and programmers but, also project managers and even higher managerial levels due to the management aspect it offers. The Basic concept of SonarQube is a set of requirements that tell whether or not a new version of a project can go into production. SonarQube automatically detects the language and provide the corresponding analysis.


Steps to implement sonarQube in the maven project:


1. Download the sonarQube server from the link -"https://www.sonarqube.org/downloads/". And then extract it.
2. Go to your maven project then add the following dependency:

    <dependency>
        <groupId>org.codehaus.sonar</groupId>
        <artifactId>sonar-maven-plugin</artifactId>
    </dependency>

3. Also, add the following profile in your pom.xml:

      <profiles>
        <profile>
            <id>sonar</id>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
            <properties>
                <!-- Optional URL to server. Default value is http://localhost:9000 -->
                <sonar.host.url>
                  http://localhost:9000
                </sonar.host.url>
            </properties>
        </profile>
     </profiles>

4. Go to "xyz/sonarQube/sonarqube-7.4/bin/Linux-x86-64(OS)" open it into the terminal. Then run the "./sonar.sh start" command to start the sonar server. The default port of the sonarQube server is 9000. You can change it according to your requirements.
5. Then go to your browser open sonarServer using localhost:9000.
6. Following are the image that shows the project report:

About Author

Author Image
Rahul Chauhan

Rahul Chauhan is Java Developer having good knowledge of java, have a knowledge of Spring Boot.

Request for Proposal

Name is required

Comment is required

Sending message..