Skip to content

Commit

Permalink
Add RuboCop
Browse files Browse the repository at this point in the history
  • Loading branch information
sferik committed Dec 31, 2013
1 parent 772200b commit 5e2af9b
Show file tree
Hide file tree
Showing 4 changed files with 91 additions and 2 deletions.
69 changes: 69 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
AllCops:
Includes:
- 'Gemfile'
- 'Rakefile'
- 'gems.gemspec'

# Avoid long parameter lists
ParameterLists:
Max: 4
CountKeywordArgs: true

MethodLength:
CountComments: false
Max: 15

# Avoid more than `Max` levels of nesting.
BlockNesting:
Max: 3

# Align with the style guide.
CollectionMethods:
PreferredMethods:
collect: 'map'
inject: 'reduce'
find: 'detect'
find_all: 'select'

# Do not force public/protected/private keyword to be indented at the same
# level as the def keyword. My personal preference is to outdent these keywords
# because I think when scanning code it makes it easier to identify the
# sections of code and visually separate them. When the keyword is at the same
# level I think it sort of blends in with the def keywords and makes it harder
# to scan the code and see where the sections are.
AccessModifierIndentation:
Enabled: false

# Limit line length
LineLength:
Enabled: false

# Disable documentation checking until a class needs to be documented once
Documentation:
Enabled: false

# Enforce Ruby 1.8-compatible hash syntax
HashSyntax:
EnforcedStyle: hash_rockets

# No spaces inside hash literals
SpaceInsideHashLiteralBraces:
EnforcedStyle: no_space

# Allow dots at the end of lines
DotPosition:
Enabled: false

# Don't require magic comment at the top of every file
Encoding:
Enabled: false

# Enforce outdenting of access modifiers (i.e. public, private, protected)
AccessModifierIndentation:
EnforcedStyle: outdent

EmptyLinesAroundAccessModifier:
Enabled: true

Lambda:
Enabled: false
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Ideally, a bug report should include a pull request with failing specs.
3. Add specs for your unimplemented feature or bug fix.
4. Run `bundle exec rake spec`. If your specs pass, return to step 3.
5. Implement your feature or bug fix.
6. Run `bundle exec rake spec`. If your specs fail, return to step 5.
6. Run `bundle exec rake`. If your specs fail, return to step 5.
7. Run `open coverage/index.html`. If your changes are not completely covered
by your tests, return to step 3.
8. Add documentation for your feature or bug fix.
Expand Down
10 changes: 10 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,19 @@ gem 'rake'
gem 'yard'
gem 'jruby-openssl', :platforms => :jruby

group :development do
gem 'pry'
gem 'pry-rescue'
platforms :ruby_19, :ruby_20 do
gem 'pry-debugger'
gem 'pry-stack_explorer'
end
end

group :test do
gem 'coveralls', :require => false
gem 'mime-types', '~> 1.25', :platforms => [:jruby, :ruby_18]
gem 'rubocop', '>= 0.16', :platforms => [:ruby_19, :ruby_20, :ruby_21]
gem 'rspec', '>= 2.11'
gem 'simplecov', :require => false
gem 'webmock'
Expand Down
12 changes: 11 additions & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,18 @@ Bundler::GemHelper.install_tasks
require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new(:spec)

task :default => :spec
task :test => :spec

require 'yard'
YARD::Rake::YardocTask.new

begin
require 'rubocop/rake_task'
Rubocop::RakeTask.new
rescue LoadError
task :rubocop do
$stderr.puts 'Rubocop is disabled'
end
end

task :default => [:spec, :rubocop]

0 comments on commit 5e2af9b

Please sign in to comment.