Every software starts with a good documentation and good code. Whenever a team starts a project are there different minds working on the same thing and sometimes this leads to differences in coding standards. To overcome this problem there are many standalone tools, which can go through your code and depending on configured rules in that tool. It gives lines of code which under coding rules violation.
There are many code quality tools in java such as,
Actually, sonar is the combination of all these, That’s the reason I prefer Sonar over the individual tool. Moreover, it has code coverage plugin as well Cobertura which is quite decent.
Steps to install Sonar and Sonar-Scanner.
Install required version of JRE.
Download latest Sonar form following link.
Read licensing and stuff (Completely optional, The current version is licensed under LGPL v3 )
Install Sonar Scanner (It’s a replacement for Sonar runner). If you are using maven and gradle then it’s not required.
Extract both the zips on one location as shown below.
Let Sonar-scanner know Sonarqube URL (Optional, If you haven’t updated the port or URL).
sonar-scanner\conf\sonar-scanner.properties –> Update the sonar.host.url Add Sonar-scanner\bin path to your system and verify by running sonar-scanner.bat -h in the console.
Spin up the Sonarqube server by running StartSonar.bat from Sonarqube bin directory and verify if it has come properly or not by going to the browser.
localhost:9000 click tutorial and make a note of the generated key.
Create sonar-project.properties in the root of the project which you want to scan.
Run solar-scanner command from the root of your project.
In case you are not using maven or gradle you might face the following issue.
Just add a follwoing line in sonar-project.properties.
sonar.java.binaries=<replace with your binaries path. bin***.class> #path of your class files.
Once you get ‘Execution Success’. Revisit your localhost:9000.
That’s setup is complete, You can browse through the site and find out the easy.