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:




2 thoughts on “Improve your Ruby code quality with metrics

  1. I have noticed you don’t monetize your website, don’t
    waste your traffic, you can earn extra bucks every month because you’ve got
    high quality content. If you want to know how to make extra money,
    search for: Mertiso’s tips best adsense alternative

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.