From 6084ffbb6522dce680433cfabda7701027373987 Mon Sep 17 00:00:00 2001 From: Matt Brictson Date: Sat, 23 Jan 2016 13:07:52 -0800 Subject: [PATCH] Add RuboCop lint to default rake task --- .travis.yml | 2 +- DEVELOPMENT.md | 8 ++++++++ Rakefile | 7 ++++++- capistrano.gemspec | 1 + 4 files changed, 16 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index baaa94fd..ae05d42b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,7 +5,7 @@ rvm: - 2.1 - 2.0 - rbx-2 -script: bundle exec rake spec +script: bundle exec rake spec lint install: bundle install --jobs=1 cache: bundler branches: diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md index 87278000..ce82fd8c 100644 --- a/DEVELOPMENT.md +++ b/DEVELOPMENT.md @@ -2,6 +2,7 @@ Thanks for helping build Capistrano! Here are the development practices followed * [Who can help](#who-can-help) * [Setting up your development environment](#setting-up-your-development-environment) +* [Coding guidelines](#coding-guidelines) * [Submitting a pull request](#submitting-a-pull-request) * [Managing GitHub issues](#managing-github-issues) * [Reviewing and merging pull requests](#reviewing-and-merging-pull-requests) @@ -52,6 +53,13 @@ Currently, the Capistrano Travis build does *not* run the Cucumber suite. This m **If you come across a failing Cucumber feature, this is a bug.** Please report it by opening a GitHub issue. Or even better: do your best to fix the feature and submit a pull request! +## Coding guidelines + +This project uses [RuboCop](https://github.com/bbatsov/rubocop) to enforce standard Ruby coding guidelines. Currently we run RuboCop's lint rules only, which check for readability issues like indentation, ambiguity, and useless/unreachable code. + +* Test that your contributions pass with `rake lint` +* The linter is also run as part of the full test suite with `rake` +* Note the Travis build will fail and your PR cannot be merged if the linter finds errors ## Submitting a pull request diff --git a/Rakefile b/Rakefile index fc943b19..06d6a182 100644 --- a/Rakefile +++ b/Rakefile @@ -1,9 +1,14 @@ require "bundler/gem_tasks" require "cucumber/rake/task" require "rspec/core/rake_task" +require "rubocop/rake_task" -task :default => :spec +task :default => [:spec, :lint] RSpec::Core::RakeTask.new Cucumber::Rake::Task.new(:features) +desc "Run RuboCop lint checks" +RuboCop::RakeTask.new(:lint) do |task| + task.options = ["--lint"] +end diff --git a/capistrano.gemspec b/capistrano.gemspec index 67ba4361..a20543f1 100644 --- a/capistrano.gemspec +++ b/capistrano.gemspec @@ -26,4 +26,5 @@ Gem::Specification.new do |gem| gem.add_development_dependency 'rspec' gem.add_development_dependency 'mocha' + gem.add_development_dependency 'rubocop' end