Sunday, 9 April 2017

How to analyze .net applications using SonarQube

            

Contents                                                                                               

1.      INTRODUCTION

1.1.       OBJECTIVE

1.2.       SCOPE

1.3.       DEFINITIONS, ACRONYMS AND ABBREVIATIONS

1.4.       REFERENCES

2.      CONTENTS

 1 . INTRODUCTION


Help those readers who want to learn how to analyze coding standards, code unit tests, and code coverage, complex code, potential bugs, comments etc. using SonarQube

It helps for various tasks and provide reports on duplicated code, coding standards, unit tests, code coverage, complex code, potential bugs, comments and design and architecture.

https://www.sonarqube.org/

  2. CONTENTS

What is sonarQube
Sonar is a web based code quality analysis tool for Maven based Java projects. It covers a wide area of code quality check points which include: Architecture & Design, Complexity, Duplications, Coding Rules, Potential Bugs, Unit Test etc.

Steps to setup Sonarqube:


Prerequisite
Ø  JDK
Ø  Visual Studio

1)      Download SonarQube 6.3here
2)      You will get a sonarqube-6.3.zip file(You can prefer if latest version is available)
3)      unzip it to a location (let's say in " C:\sonarqube")
4)      Download SonarQube Scanner for MSBuild from here
5)      You will get a sonar-scanner-msbuild-2.2.0.24.zip file (versions might be differing in future)
6)      unzip it to a location (let's say in " C:\sonarqube")
7)      Set the environment variables for SonarQube, Sonarqube-scanner-msbuild
8)      Follow the below screen shots to set environment variables




                  9)      Execute the following to start SonarQube server:
On Windows,
è StartSonar
Note : if you are not setting environment variables for sonarqube then you have to give full path like below
è cd C: \sonarqube\sonarqube-6.3\bin\windows-x86-64
è StartSonar.bat
                 10)  The sonar is up and running as shown below:

Step 11: Give path of your .net project. In my case I have given the following path
Ø  cd C:\InternalProject\Sprint3\Hosts\OSITDC.Host.ServiceApi
Ø  then enter the following command in command prompt
Ø  SonarQube.Scanner.MSBuild.exe begin /k:"OSITDC.Host.ServiceApi" /n:"OSITDC.Host.ServiceApi" /v:"1.0"
Ø  MSBuild.exe /t:Rebuild
Ø  SonarQube.Scanner.MSBuild.exe end
Here OSITDC.Host.ServiceApi is my .net project name , once the analysis finished you can try to access the sonarqube default site

Ø  localhost:9000  open this page from your browser and you can see your project analysis there





No comments:

Post a Comment