Quality Assurance With Sonar
Join the DZone community and get the full member experience.
Join For FreeIt's incredible how unknown a tool like Sonar is yet. I guess Gradle suffers the same destiny. After all, they're both similar in their intent, improve the quality of your software. It seems lots of people know about unit testing (not so many about code coverage), less know about tools like Checkstyle or FindBugs (static analysis of code) and just a minority are aware of other esoteric metrics like cyclomatic complexity. And even the few that use all of them do not extract all the value that a dashboard provides. That's what Sonar handles, it will take your project and stress it showing the results in a visually appealing site. With no extra work from you, the only requirement is to use Ant or, preferably, Maven.
But seeing is believing so I'll try to convince you showing the whole process and what kind of enhancements you'll be getting. As the demo project I've chosen IWebMvc2. I've nearly finished the development by now so it's a perfect timing to improve quality. In addition it's a complex web application made of three different sub-projects so something must arise. IMHO the quality of the code is pretty good, in theory I just want proofs...did I just say humble? ;-).
The first task is downloading the project and installing it. It's trivial believe me (well as long as you know how to unpack an archive...). To run Sonar just go to the bin folder, select your OS and execute the provided script. Trivial again. Sonar show be accessible (although empty) at http://localhost:9000 by now. Go there and login with admin/admin. Select configuration and under Quality Profiles click on Sonar way with Findbugs: set as default.
Next step is to build our project and include the Sonar phase. This is done typing:
Pretty easy, wasn't it? If the project was built successfully the console was updated and shows something like:
Here's
the bread and butter! All kind of metrics! From the whole project. The
graphic displays the number of modules (JARs) and the relative size of
each one. It's used to drill down and get module specific statistics.
In fact, every link allows to navigate to new pages with deeper details.
Our task is to improve the quality of the project (bit by bit) so we can navigate to the Violations section and get a detailed report of the problems:
Opinions expressed by DZone contributors are their own.
Comments