Quality Control is a ruby gem that unifies continous integration tasks (linting, test running, coverage reporting) into reusable rake tasks, currently supports the following plugins.
Just add it to your gem file:
gem 'quality_control', github: 'gdotdesign/quality_control'
Then in your Rakefile require it and other plugins that you need:
require 'quality_control'
require 'quality_control/rubocop'
require 'quality_control/yard'
Then configure gem and the plugins:
QualityControl::Rubocop.directories += %w(lib)
QualityControl::Yard.treshold = 98
QualityControl.tasks += %w(syntax:ruby documentation:coverage)
Quality Control defines a rake task called ci
which runs all the tasks that are defined in the QualityControl.tasks
variable. If configured correctly, running rake ci
will show something like this:
✘ - Run a Ruby syntax check
✔ - Run a SCSS syntax check
✘ - Check documentation coverage
✔ - Run opal specs in phantomjs
✘ - Check opal specs coverage
The ✘
before the tasks means it has failed, the ✔
means it has succeeded. If any of the tasks fail the exit code will be 1 else it will be 0. That means that you can hook it up into your CI Server.
This plugin provides static code analysis coverage via Rubycritic:
require 'quality_control/rubycritic'
# The directories to run rubocop on.
QualityControl::Rubycritic.directories += %w(lib)
# The threshold for the score
QualityControl::Rubycritic.score_threshold = 100
# The threshold for the rating A-F
QualityControl::Rubycritic.rating_threshold = 'B'
Provies tasks rubycritic:generate
, rubycritic:coverage
This plugin provides Ruby language linting via RuboCop:
require 'quality_control/rubocop'
# The directories to run rubocop on.
QualityControl::Rubocop.directories += %w(lib)
Provies the task syntax:ruby
This plugin provides SCSS language linting via SCSS-Lint:
require 'quality_control/scss'
# The directories to run scss-lint on.
QualityControl::SCSS.directories += %w(lib)
Provies the task syntax:scss
This plugin provides documentation coverage test via YARD:
require 'quality_control/yard'
# The threshold for the coverage in percentage
QualityControl::Yard.threshold = 98
Provides tasks documentation:generate
and documentation:coverage
This plugin provides test coverage for frontend Ruby files via Opal and Opal RSpec:
require 'quality_control/opal_rspec'
# Regexp to match the files need to be covered.
QualityControl::OpalRspec.files = /^source.*\.rb/
# The threshold for the coverage in percentage
QualityControl::OpalRspec.threshold = 90
Then you will need to add the following to your spec_helper.rb
or similar file:
require 'rspec_coverage_helper'
Provides tasks opal:rspec and opal:rspec:coverage.
Custom tasks can be added to the CI tasks by appending it to the tasks
variable:
namespace :my do
namespace :rake do
task :task do
fail if ENV['test'] == 'on'
end
end
end
QualityControl.tasks << 'my:rake:task'
If the specified task calls fail
or raise
, it will be displayed as a failure.