Skip to content

Commit c34f0d5

Browse files
committed
Fix Rubocop lint warnings
lib/kracken/controllers/json_api_compatible.rb:108:7: W: Lint/UselessAccessModifier: Useless private access modifier. private ^^^^^^^ lib/kracken/controllers/token_authenticatable.rb:28:70: W: Lint/UnusedMethodArgument: Unused method argument - message. If it's necessary, use _ or _message as an argument name to indicate that it won't be used. def request_http_token_authentication(realm = 'Application', message = nil) ^^^^^^^ lib/kracken/controllers/token_authenticatable.rb:118:30: W: Lint/AssignmentInCondition: Use == if you meant to do a comparison or wrap the expression in parentheses to indicate you meant to assign in a condition. if @current_user = Authenticator.user_with_token(token) ^ lib/kracken/engine.rb:9:40: W: Lint/UnusedBlockArgument: Unused block argument - app. You can omit the argument if you don't care about it. initializer "kracken.omniauth" do |app| ^^^ lib/kracken/env.rb:11:1: W: Lint/HandleExceptions: Do not suppress exceptions. rescue LoadError ^^^^^^^^^^^^^^^^ lib/kracken/json_api/public_exceptions.rb:64:7: W: Lint/RescueException: Avoid rescuing the Exception class. Perhaps you meant to rescue StandardError? rescue Exception => exception ... ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ lib/kracken/json_api/public_exceptions.rb:83:32: W: Lint/UnusedMethodArgument: Unused method argument - error. If it's necessary, use _ or _error as an argument name to indicate that it won't be used. You can also write as additional_details(*) if you want the method to accept any arguments but don't care about them. def additional_details(error) ^^^^^ lib/kracken.rb:20:19: W: Lint/UnusedMethodArgument: Unused method argument - block. If it's necessary, use _ or _block as an argument name to indicate that it won't be used. You can also write as setup(*) if you want the method to accept any arguments but don't care about them. def self.setup(&block) ^^^^^ lib/omniauth/strategies/radius.rb:8:1: W: Lint/HandleExceptions: Do not suppress exceptions. rescue LoadError ^^^^^^^^^^^^^^^^ lib/omniauth/strategies/radius.rb:29:11: W: Lint/UnneededSplatExpansion: Pass array contents as separate arguments. *%w{ ... ^^^^ spec/kracken/controllers/token_authenticatable_spec.rb:19:49: W: Lint/UnusedMethodArgument: Unused method argument - realm. If it's necessary, use _ or _realm as an argument name to indicate that it won't be used. You can also write as authenticate_or_request_with_http_token(*) if you want the method to accept any arguments but don't care about them. def authenticate_or_request_with_http_token(realm = nil) ^^^^^ spec/requests/api_spec.rb:17:28: W: Lint/UnusedMethodArgument: Unused method argument - path. If it's necessary, use _ or _path as an argument name to indicate that it won't be used. def request_resource(path, params: {}, headers: {}) ^^^^ spec/requests/api_spec.rb:21:28: W: Lint/UnusedMethodArgument: Unused method argument - path. If it's necessary, use _ or _path as an argument name to indicate that it won't be used. def request_resource(path, params: {}, headers: {}) ^^^^
1 parent 45ed70b commit c34f0d5

File tree

9 files changed

+23
-25
lines changed

9 files changed

+23
-25
lines changed

lib/kracken.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ module Kracken
1717
mattr_accessor :config
1818
@@config = Config.new
1919

20-
def self.setup(&block)
20+
def self.setup
2121
yield @@config
2222
end
2323
end

lib/kracken/controllers/json_api_compatible.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,8 @@ def negotiate_mime
105105
raise ::ActionController::UnknownFormat
106106
end
107107

108-
private
109-
110108
ALLOWED_MEDIA_TYPES = [Mime[:json]].freeze
109+
private_constant :ALLOWED_MEDIA_TYPES
111110
end
112111
include DataIntegrity
113112

lib/kracken/controllers/token_authenticatable.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def self.included(base)
2525
#
2626
# Modified from https://github.com/rails/rails/blob/60d0aec7/actionpack/lib/action_controller/metal/http_authentication.rb#L490-L499
2727
if Rails::VERSION::MAJOR >= 5
28-
def request_http_token_authentication(realm = 'Application', message = nil)
28+
def request_http_token_authentication(realm = 'Application', _message = nil)
2929
headers["WWW-Authenticate"] = %(Token realm="#{realm.gsub(/"/, "")}")
3030
raise TokenUnauthorized, "Invalid Credentials"
3131
end
@@ -115,7 +115,7 @@ def authenticate_user_with_token!
115115
authenticate_or_request_with_http_token(realm) { |token, _options|
116116
# Attempt to reduce ivar namespace conflicts with controllers
117117
@_auth_info = cache_valid_auth(token) {
118-
if @current_user = Authenticator.user_with_token(token)
118+
if (@current_user = Authenticator.user_with_token(token))
119119
{ id: @current_user.id, team_ids: @current_user.team_ids }
120120
end
121121
}

lib/kracken/engine.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ module Kracken
66
class Engine < ::Rails::Engine
77
isolate_namespace Kracken
88

9-
initializer "kracken.omniauth" do |app|
9+
initializer "kracken.omniauth" do |_app|
1010
Rails.application.config.middleware.use OmniAuth::Builder do
1111
provider :radius, Kracken.config.app_id, Kracken.config.app_secret
1212
end

lib/kracken/env.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
# frozen_string_literal: true
32

43
# If this gem is loaded via bundler before the rails initializer we need to
@@ -8,7 +7,8 @@
87
begin
98
require 'dotenv'
109
Dotenv.load
11-
rescue LoadError
10+
rescue LoadError => e
11+
raise unless e.message.include?('dotenv')
1212
end
1313

1414
module Kracken

lib/kracken/json_api/public_exceptions.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def capture_error(env)
6161
end
6262

6363
response
64-
rescue Exception => exception
64+
rescue Exception => exception # rubocop:disable Lint/RescueException
6565
wrapper = exception_wrapper(env, exception)
6666
log_error(env, wrapper)
6767
render_json_error(wrapper)
@@ -80,7 +80,7 @@ def exception_wrapper(env, exception)
8080
end
8181

8282
if Rails.env.production?
83-
def additional_details(error)
83+
def additional_details(_error)
8484
{}
8585
end
8686
else

lib/omniauth/strategies/radius.rb

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
begin
66
require 'dotenv'
77
Dotenv.load
8-
rescue LoadError
8+
rescue LoadError => e
9+
raise unless e.message.include?('dotenv')
910
end
1011

1112
module OmniAuth
@@ -26,17 +27,15 @@ def self.provider_url
2627

2728
info do
2829
raw_info["info"].slice(
29-
*%w{
30-
first_name
31-
last_name
32-
email
33-
uid
34-
confirmed
35-
teams
36-
linked_accounts
37-
admin
38-
subscription_level
39-
}
30+
"first_name",
31+
"last_name",
32+
"email",
33+
"uid",
34+
"confirmed",
35+
"teams",
36+
"linked_accounts",
37+
"admin",
38+
"subscription_level",
4039
)
4140
end
4241

spec/kracken/controllers/token_authenticatable_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class TokenAuthController < BaseControllerDouble
1616
:current_user,
1717
:current_user_id
1818

19-
def authenticate_or_request_with_http_token(realm = nil)
19+
def authenticate_or_request_with_http_token(_realm = nil)
2020
/\AToken token="(?<token>.*)"\z/ =~ request.env['HTTP_AUTHORIZATION']
2121
yield token if block_given?
2222
end

spec/requests/api_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ def headers_with_token(token)
1414

1515
# Temporary work around while we support versions of Rails before 4
1616
if Rails::VERSION::MAJOR >= 5
17-
def request_resource(path, params: {}, headers: {})
17+
def request_resource(_path, params: {}, headers: {})
1818
get api_index_path, params: params, headers: headers
1919
end
2020
else
21-
def request_resource(path, params: {}, headers: {})
21+
def request_resource(_path, params: {}, headers: {})
2222
get api_index_path, params, headers
2323
end
2424
end

0 commit comments

Comments
 (0)