Tag Archives: jenkins

Improve your Ruby code quality with metrics

In the ruby world we have several tools to analyse our ruby (and Rails) code. In this article we will see the most used (and useful for me), and how to integrate into our CI process with Jenkins.

These gems are:

In your Gemfile you should include all gems:

 # Metrics
 gem 'simplecov', require: false
 gem 'simplecov-rcov', require: false
 gem 'rubocop', require: false
 gem 'rails_best_practices', require: false
 gem 'metric_fu', require: false

Simplecov needs some configuration at the beginning of your ‘spec_helper.rb’ to generate the coverage files:

require 'simplecov'
require 'simplecov-rcov'
SimpleCov.formatter = SimpleCov::Formatter::RcovFormatter
SimpleCov.start 'rails'

That’s all done in your Rails project. Now you need to install two plugins in your Jenkins server:

Finally I have configured my metrics build as:

build-configuration