Permalink
Browse files

Add RuboCop

  • Loading branch information...
1 parent 6344607 commit a163a428800d5925755d31a4494c966f12f9848b @sferik sferik committed Dec 31, 2013
Showing with 95 additions and 9 deletions.
  1. +1 −2 .rspec
  2. +72 −0 .rubocop.yml
  3. +1 −0 .travis.yml
  4. +8 −4 Gemfile
  5. +13 −3 Rakefile
View
3 .rspec
@@ -1,3 +1,2 @@
--color
---format=nested
---backtrace
+--order random
View
@@ -0,0 +1,72 @@
+AllCops:
+ Includes:
+ - 'Gemfile'
+ - 'Rakefile'
+ - 'congress.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
+
+NumericLiterals:
+ Enabled: false
View
@@ -1,3 +1,4 @@
+bundler_args: --without development
language: ruby
rvm:
- 1.8.7
View
12 Gemfile
@@ -1,20 +1,24 @@
source 'https://rubygems.org'
gem 'rake'
-
-platforms :jruby do
- gem 'jruby-openssl', '~> 0.7'
-end
+gem 'jruby-openssl', :platforms => :jruby
group :development do
gem 'kramdown'
+ gem 'pry'
+ gem 'pry-rescue'
gem 'yard'
+ 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 'rspec'
+ gem 'rubocop', '>= 0.16', :platforms => [:ruby_19, :ruby_20, :ruby_21]
gem 'simplecov', :require => false
gem 'webmock'
end
View
@@ -4,13 +4,23 @@ Bundler::GemHelper.install_tasks
require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new(:spec)
-task :default => :spec
task :test => :spec
require 'yard'
namespace :doc do
YARD::Rake::YardocTask.new do |task|
- task.files = ['lib/**/*.rb']
- task.options = ['--markup', 'markdown']
+ task.files = %w[lib/**/*.rb]
+ task.options = %w[--markup markdown]
end
end
+
+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 a163a42

Please sign in to comment.