Skip to content

Commit

Permalink
Update rubocop dependency to >= 0.25
Browse files Browse the repository at this point in the history
  • Loading branch information
sferik committed Aug 18, 2014
1 parent 82e248f commit ba57ea5
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 73 deletions.
91 changes: 32 additions & 59 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,82 +1,55 @@
AllCops:
Include:
- 'Gemfile'
- 'Rakefile'
- 'oauth2.gemspec'
Metrics/BlockNesting:
Max: 2

# Avoid long parameter lists
ParameterLists:
Max: 4
CountKeywordArgs: true
Metrics/LineLength:
AllowURI: true
Enabled: false

MethodLength:
Metrics/MethodLength:
CountComments: false
Max: 15

# Avoid more than `Max` levels of nesting.
BlockNesting:
Max: 3
Metrics/ParameterLists:
Max: 4
CountKeywordArgs: true

Lint/UnusedBlockArgument:
Exclude:
- 'spec/**/*.rb'

Style/AccessModifierIndentation:
EnforcedStyle: outdent

# Align with the style guide.
CollectionMethods:
Style/CollectionMethods:
PreferredMethods:
collect: 'map'
inject: 'reduce'
map: 'collect'
reduce: 'inject'
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:
Style/Documentation:
Enabled: false

# Limit line length
LineLength:
Enabled: false
Style/DotPosition:
EnforcedStyle: trailing

# Disable documentation checking until a class needs to be documented once
Documentation:
Style/DoubleNegation:
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:
Style/EachWithObject:
Enabled: false

# Don't require magic comment at the top of every file
Encoding:
Style/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
Style/HashSyntax:
EnforcedStyle: hash_rockets

Lambda:
Style/Lambda:
Enabled: false

UnusedBlockArgument:
Enabled: false
Style/SpaceInsideHashLiteralBraces:
EnforcedStyle: no_space

Style/TrailingComma:
EnforcedStyleForMultiline: 'comma'
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ env:
language: ruby
rvm:
- 1.8.7
- 1.9.2
- 1.9.3
- 2.0.0
- 2.1
Expand Down
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ group :test do
gem 'mime-types', '~> 1.25', :platforms => [:jruby, :ruby_18]
gem 'rest-client', '~> 1.6.0', :platforms => [:jruby, :ruby_18]
gem 'rspec', '>= 3'
gem 'rubocop', '>= 0.23', :platforms => [:ruby_19, :ruby_20, :ruby_21]
gem 'rubocop', '>= 0.25', :platforms => [:ruby_19, :ruby_20, :ruby_21]
gem 'simplecov', '>= 0.9'
gem 'yardstick'
end
Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ This library aims to support and is [tested against][travis] the following Ruby
implementations:

* Ruby 1.8.7
* Ruby 1.9.2
* Ruby 1.9.3
* Ruby 2.0.0
* Ruby 2.1.0
Expand Down
10 changes: 4 additions & 6 deletions lib/oauth2/mac_token.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,7 @@ class MACToken < AccessToken
# @param [Hash] opts the options to create the Access Token with
# @see MACToken#initialize
def self.from_access_token(token, secret, options = {})
new(token.client, token.token, secret, token.params.merge(
:refresh_token => token.refresh_token,
:expires_in => token.expires_in,
:expires_at => token.expires_at
).merge(options))
new(token.client, token.token, secret, token.params.merge(:refresh_token => token.refresh_token, :expires_in => token.expires_in, :expires_at => token.expires_at).merge(options))
end

attr_reader :secret, :algorithm
Expand Down Expand Up @@ -99,14 +95,16 @@ def signature(timestamp, nonce, verb, uri)
#
# @param [String] alg the algorithm to use (one of 'hmac-sha-1', 'hmac-sha-256')
def algorithm=(alg)
@algorithm = case alg.to_s
@algorithm = begin
case alg.to_s
when 'hmac-sha-1'
OpenSSL::Digest::SHA1.new
when 'hmac-sha-256'
OpenSSL::Digest::SHA256.new
else
fail(ArgumentError, 'Unsupported algorithm')
end
end
end

private
Expand Down
4 changes: 2 additions & 2 deletions lib/oauth2/response.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,15 @@ def body
PARSERS = {
:json => lambda { |body| MultiJson.load(body) rescue body }, # rubocop:disable RescueModifier
:query => lambda { |body| Rack::Utils.parse_query(body) },
:text => lambda { |body| body }
:text => lambda { |body| body },
}

# Content type assignments for various potential HTTP content types.
CONTENT_TYPES = {
'application/json' => :json,
'text/javascript' => :json,
'application/x-www-form-urlencoded' => :query,
'text/plain' => :text
'text/plain' => :text,
}

# The parsed response body.
Expand Down
4 changes: 2 additions & 2 deletions lib/oauth2/strategy/assertion.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,15 @@ def build_request(params)
{:grant_type => 'assertion',
:assertion_type => 'urn:ietf:params:oauth:grant-type:jwt-bearer',
:assertion => assertion,
:scope => params[:scope]
:scope => params[:scope],
}.merge(client_params)
end

def build_assertion(params)
claims = {:iss => params[:iss],
:aud => params[:aud],
:prn => params[:prn],
:exp => params[:exp]
:exp => params[:exp],
}
if params[:hmac_secret]
JWT.encode(claims, params[:hmac_secret], 'HS256')
Expand Down
2 changes: 1 addition & 1 deletion spec/oauth2/strategy/client_credentials_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
it 'generates an Authorization header value for HTTP Basic Authentication' do
[
['abc', 'def', 'Basic YWJjOmRlZg=='],
['xxx', 'secret', 'Basic eHh4OnNlY3JldA==']
['xxx', 'secret', 'Basic eHh4OnNlY3JldA=='],
].each do |client_id, client_secret, expected|
expect(subject.authorization(client_id, client_secret)).to eq(expected)
end
Expand Down

0 comments on commit ba57ea5

Please sign in to comment.