From 595ab454c106a48655b41fc2e94d883259dca837 Mon Sep 17 00:00:00 2001 From: Erik Michaels-Ober Date: Mon, 24 Mar 2014 10:58:48 +0100 Subject: [PATCH] Add RuboCop --- .rubocop.yml | 89 ++++++++++++++++++++++++++++++++++++++ Gemfile | 4 +- Rakefile | 13 +++++- lib/simple_oauth/header.rb | 2 +- 4 files changed, 105 insertions(+), 3 deletions(-) create mode 100644 .rubocop.yml diff --git a/.rubocop.yml b/.rubocop.yml new file mode 100644 index 0000000..9c8c521 --- /dev/null +++ b/.rubocop.yml @@ -0,0 +1,89 @@ +AllCops: + Includes: + - 'Gemfile' + - 'Rakefile' + - 'simple_oauth.gemspec' + +# Avoid long parameter lists +ParameterLists: + Max: 4 + CountKeywordArgs: true + +ClassLength: + Max: 100 + +LineLength: + Enabled: false + +MethodLength: + CountComments: false + Max: 7 + +# Avoid more than `Max` levels of nesting. +BlockNesting: + Max: 1 + +# Align with the style guide. +CollectionMethods: + PreferredMethods: + map: 'collect' + reduce: 'inject' + find: 'detect' + find_all: 'select' + +# 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 + +# Align ends correctly +EndAlignment: + AlignWith: variable + +# Indentation of when/else +CaseIndentation: + IndentWhenRelativeTo: end + IndentOneStep: false + +Lambda: + Enabled: false + +RaiseArgs: + EnforcedStyle: compact + +TrailingComma: + Enabled: false + +PercentLiteralDelimiters: + PreferredDelimiters: + '%': () + '%i': () + '%q': () + '%Q': () + '%r': '{}' + '%s': () + '%w': '[]' + '%W': '[]' + '%x': () diff --git a/Gemfile b/Gemfile index 3ee6f6f..62818cf 100644 --- a/Gemfile +++ b/Gemfile @@ -5,7 +5,9 @@ gem 'rake' group :test do gem 'coveralls', :require => false - gem 'rspec', '>= 2.11' + gem 'mime-types', '~> 1.25', :platforms => [:jruby, :ruby_18] + gem 'rspec', '>= 2.14' + gem 'rubocop', '>= 0.19', :platforms => [:ruby_19, :ruby_20, :ruby_21] gem 'simplecov', :require => false end diff --git a/Rakefile b/Rakefile index 93cb943..5f6ad94 100644 --- a/Rakefile +++ b/Rakefile @@ -3,4 +3,15 @@ require 'rspec/core/rake_task' RSpec::Core::RakeTask.new(:spec) -task :default => :spec +task :test => :spec + +begin + require 'rubocop/rake_task' + Rubocop::RakeTask.new +rescue LoadError + task :rubocop do + $stderr.puts 'Rubocop is disabled' + end +end + +task :default => [:spec, :rubocop] diff --git a/lib/simple_oauth/header.rb b/lib/simple_oauth/header.rb index 8468df5..ed3346a 100644 --- a/lib/simple_oauth/header.rb +++ b/lib/simple_oauth/header.rb @@ -14,7 +14,7 @@ module SimpleOAuth :nonce => OpenSSL::Random.random_bytes(16).unpack('H*')[0], :signature_method => 'HMAC-SHA1', :timestamp => Time.now.to_i.to_s, - :version => '1.0' + :version => '1.0', } end