Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add rubocop --lint to default rake task and Travis build #1571

Merged
merged 2 commits into from
Jan 24, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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