Skip to content

Commit

Permalink
Merge pull request capistrano#1571 from mattbrictson/rubocop-lint
Browse files Browse the repository at this point in the history
Add `rubocop --lint` to default rake task and Travis build
  • Loading branch information
leehambley committed Jan 24, 2016
2 parents e407c00 + 48ee87c commit a19b0d9
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
8 changes: 8 additions & 0 deletions DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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

Expand Down
7 changes: 6 additions & 1 deletion Rakefile
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions capistrano.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -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
17 changes: 9 additions & 8 deletions lib/capistrano/configuration/server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,15 @@ def has_role?(role)
def select?(options)
options.each do |k,v|
callable = v.respond_to?(:call) ? v: ->(server){server.fetch(v)}
result = case k
when :filter, :select
callable.call(self)
when :exclude
!callable.call(self)
else
self.fetch(k) == v
end
result = \
case k
when :filter, :select
callable.call(self)
when :exclude
!callable.call(self)
else
self.fetch(k) == v
end
return false unless result
end
return true
Expand Down
2 changes: 1 addition & 1 deletion spec/lib/capistrano/application_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def flags(*sets)

def command_line(*options)
options.each { |opt| ARGV << opt }
def subject.exit(*_args)
subject.define_singleton_method(:exit) do |*_args|
throw(:system_exit, :exit)
end
subject.run
Expand Down

0 comments on commit a19b0d9

Please sign in to comment.