I’ve been working with a number of initiatives aimed for code quality in Grails projects. I’ve found some great plugins like CodeNarc, GMetrics, … but before we talk about them and how to run in Grails projects I would like go through on how to expose those quality metrics in a fancy dashboard.
Here comes into play a platform to manage code quality: SonarQube. It has a number of plugins for rules, metrics and different languages, in our case: Groovy.
SonarQube has very efficient way to navigate between low and high-level view, dashboards and defect hunting. It enables to quickly uncover projects / components which are in technical debt to institute action plans.
The purpose of this post is not exactly show how to install SonarQube but share a virtual box already fitted with the whole environment for Grails projects. In order to set up this box I used Vagrant, provisioning with shell scripts and Oracle Virtual Box.
Vagrant is an exceptional tool to set up environments, if you don’t know about it click here. I have chosen shell scripts at this time, maybe next box I will use puppet or chef.
To run this environment simply install Vagrant, Oracle VM and clone my project from GitHub.
$ git clone https://github.com/cassiodias/environment_automation.git $ cd gr8-sonar-box $ vagrant up
Get up and grab a coffee, it will take a few minutes for the first time because need to download all the required tools. When finished, go to: http://192.168.33.57:9000.
To turn off the VM just run $ vagrant halt or $ vagrant suspend. More Vagrant commands here.
Basically this provisioning install ubuntu 64b OS, JDK 7 (could be just JRE), PostgreSQL 9.1 with remote access already configured, SonarQube 5.1.2 with groovy plugin 1.2 and VM box forwarding to 192.168.33.57.
Next post I will explain how to collect and export data using the plugins I mentioned at the beginning of the post.
Hopefully this box can be useful and feel free to clone, modify and pull request.