Measurement and determination of the code quality is an eternal theme in the programming world. All the experts who already have experience with large projects with a long history do not doubt about the need to maintain the code in good quality. But there is not always enough time to find out what characteristics and metrics are important in this project. However, it appears in most of the cases cases that it is enough manage the following characteristics:

  • compliance with the rules;
  • the complexity of the code;
  • duplicates;
  • commenting;
  • covering tests.

And there is a great tool to do all the stuff – Sonarqube. Below is a simple guide how to install this tool onto your local server.

    1. Download and extract SonarQube, SonarQube runner and the examples.
    2. Download java if you need to (search for java first).a. If you downloaded java 8 it will be in this directory: C:\Program Files (x86)\Java\jre1.8.0_31\bin
    3. Amend the wrapper.conf file (in the conf dir):From:
      To:\Program Files (x86)\Java\jre7\bin\java
      To:\Program Files (x86)\Java\jre1.8.0_31\bin\java
      Note: Default is now so if java is in the PATH no need to edit this file
    4. cd to sonar bin/windows-x86-32 directory and run StartSonar.bat
      Note: There is now a bin/windows-x86-64 directory, this works with windows server 2012
    5. Test server by going to http://localhost:9000, there should be a blank SonarQube page.
    6. Go to the settings page on SonarQube, may need to log in (default is admin/admin)
    7. Click on the update center (left hand side of the screen)
    8. Click on available plugins and add c#, javascript and dotnet.
    9. Stop and restart the SonarQube server
    10. Configure the settings by clicking on “General Settings”.
    11. Setup .Net FxCop by clicking on .Net FxCop and changing the install directory to C:\Program Files (x86)\Microsoft Visual Studio 11.0\Team Tools\Static Analysis Tools\FxCop