Skip to content

Commit

Permalink
Disable reek and fix rest of cops
Browse files Browse the repository at this point in the history
  • Loading branch information
waiting-for-dev committed Jul 11, 2020
1 parent 407550b commit 2720938
Show file tree
Hide file tree
Showing 10 changed files with 8 additions and 28 deletions.
2 changes: 0 additions & 2 deletions .codeclimate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ engines:
enabled: true
rubocop:
enabled: true
reek:
enabled: true
ratings:
paths:
- "**.rb"
Expand Down
3 changes: 0 additions & 3 deletions .overcommit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,6 @@ PreCommit:
- *default_excludes
- bin/*

Reek:
enabled: true

RuboCop:
enabled: true

Expand Down
3 changes: 0 additions & 3 deletions .overcommit_gems.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@
# Patch-level verification for Bundled apps
gem 'bundler-audit', '~> 0.5'

# Ruby code smell reporter
gem 'reek', '~> 4.5'

# Ruby code style checking
gem 'rubocop', '~> 0.47'
gem 'rubocop-rspec', '~> 1.10'
16 changes: 8 additions & 8 deletions lib/devise/jwt.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,27 +28,27 @@ def self.jwt
module JWT
extend Dry::Configurable

def forward_to_warden(setting, value)
default = Warden::JWTAuth.config.send("#{setting}")
def self.forward_to_warden(setting, value)
default = Warden::JWTAuth.config.send(setting)
Warden::JWTAuth.config.send("#{setting}=", value || default)
Warden::JWTAuth.config.send("#{setting}")
Warden::JWTAuth.config.send(setting)
end

module_function :forward_to_warden

setting(:secret, Warden::JWTAuth.config.secret) do |value|
forward_to_warden(:secret, value)
end

setting(:expiration_time, Warden::JWTAuth.config.expiration_time ) do |value|
setting(:expiration_time, Warden::JWTAuth.config.expiration_time) do |value|
forward_to_warden(:expiration_time, value)
end

setting(:dispatch_requests, Warden::JWTAuth.config.dispatch_requests) do |value|
setting(:dispatch_requests,
Warden::JWTAuth.config.dispatch_requests) do |value|
forward_to_warden(:dispatch_requests, value)
end

setting(:revocation_requests, Warden::JWTAuth.config.revocation_requests) do |value|
setting(:revocation_requests,
Warden::JWTAuth.config.revocation_requests) do |value|
forward_to_warden(:revocation_requests, value)
end

Expand Down
4 changes: 0 additions & 4 deletions lib/devise/jwt/defaults_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,12 @@ def add_defaults(inspector)
add_revocation_requests(inspector)
end

# :reek:FeatureEnvy
def add_mapping(inspector)
scope = inspector.scope
model = inspector.model
defaults[:mappings][scope] = model.name
end

# :reek:FeatureEnvy
def add_revocation_strategy(inspector)
scope = inspector.scope
strategy = inspector.model.jwt_revocation_strategy
Expand Down Expand Up @@ -91,7 +89,6 @@ def registration_requests(inspector)
requests(inspector, :registration)
end

# :reek:FeatureEnvy
def requests(inspector, name)
path = inspector.path(name)
methods = inspector.methods(name)
Expand All @@ -100,7 +97,6 @@ def requests(inspector, name)
end
end

# :reek:UtilityFunction
def requests_for_format(path, methods, format)
path_regexp = format ? /^#{path}.#{format}$/ : /^#{path}$/
methods.map do |method|
Expand Down
2 changes: 0 additions & 2 deletions lib/devise/jwt/mapping_inspector.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,13 @@ def model
mapping.to
end

# :reek:FeatureEnvy
def path(name)
prefix, scope, request = path_parts(name)
[prefix, scope, request].delete_if do |item|
!item || item.empty?
end.join('/').prepend('/').gsub('//', '/')
end

# :reek:ControlParameter
def methods(name)
method = case name
when :sign_in then 'POST'
Expand Down
1 change: 0 additions & 1 deletion lib/devise/jwt/revocation_strategies/allowlist.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ def self.revoke_jwt(payload, user)
end

# Warden::JWTAuth::Interfaces::User#on_jwt_dispatch
# :reek:FeatureEnvy
def on_jwt_dispatch(_token, payload)
allowlisted_jwts.create!(
jti: payload['jti'],
Expand Down
3 changes: 0 additions & 3 deletions lib/devise/jwt/test_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@ module TestHelpers
# autodetected.
# @param aud [String] The aud claim. If `nil` it will be autodetected from
# the header name configured in `Devise::JWT.config.aud_header`.
#
# :reek:LongParameterList
# :reek:ManualDispatch
def self.auth_headers(headers, user, scope: nil, aud: nil)
scope ||= Devise::Mapping.find_scope!(user)
aud ||= headers[Warden::JWTAuth.config.aud_header]
Expand Down
1 change: 0 additions & 1 deletion spec/devise/jwt/test_helpers_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
let(:headers) { { 'foo' => 'bar', 'JWT_AUD' => 'client' } }
let(:user) { jwt_with_jti_matcher_user }

# :reek:UtilityFunction
def payload_from_headers(headers)
_method, token = headers['Authorization'].split
Warden::JWTAuth::TokenDecoder.new.call(token)
Expand Down
1 change: 0 additions & 1 deletion spec/support/shared_contexts/feature.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ def sign_up(registration_path, params, format: nil)
post(path, params: params)
end

# :reek:LongParameterList
def sign_out(destroy_session_path, auth, method = :delete, format: nil)
path = format ? destroy_session_path + ".#{format}" : destroy_session_path
send(method, path, headers: auth_headers(auth))
Expand Down

0 comments on commit 2720938

Please sign in to comment.