Showing 13 of 15 total issues
Method included
has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring. Open
def self.included(base)
base.helpers do
def throw_unauthorized(message)
throw(:warden, errors: message)
end
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method included
has 94 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.included(base)
base.helpers do
def throw_unauthorized(message)
throw(:warden, errors: message)
end
Method included
has 68 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.included(base)
base.helpers do
def auth_hash
@auth_hash ||= begin
hash = request.env['rack.session'].delete('gta.omniauth.auth')
Method included
has 53 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.included(base)
base.serialize :tokens, JSON
base.after_initialize { self.tokens ||= {} }
base.validates :password, presence: true, on: :create
base.validate :password_confirmation_matches,
Method included
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.included(base)
base.helpers do
def find_resource(data, mapping)
token_authorizer = TokenAuthorizer.new(data)
token_authorizer.find_resource(mapping)
Method included
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def self.included(base)
base.helpers do
def find_resource(data, mapping)
token_authorizer = TokenAuthorizer.new(data)
token_authorizer.find_resource(mapping)
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method included
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def self.included(base)
base.helpers do
def auth_hash
@auth_hash ||= begin
hash = request.env['rack.session'].delete('gta.omniauth.auth')
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method token_is_current?
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def token_is_current?(token, client_id)
client_id_info = tokens[client_id]
expiry = client_id_info['expiry'] || client_id_info[:expiry]
token_hash = client_id_info['token'] || client_id_info[:token]
return false unless expiry && token
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method initialize
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def initialize(uid = nil, client_id = nil, token = nil,
expiry = nil, warden = nil)
Method token_can_be_reused?
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def token_can_be_reused?(token, client_id)
updated_at = fetch_with_indifference(tokens[client_id], :updated_at)
last_token = fetch_with_indifference(tokens[client_id], :last_token)
return false unless updated_at && last_token
return false unless within_batch_window?(Time.parse(updated_at))
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method whitelisted_params
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def whitelisted_params
whitelist = GrapeTokenAuth.configuration.param_white_list
return unless whitelist
scoped_list = whitelist[scope] || whitelist[scope.to_s]
return unless scoped_list
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method find_resource
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def find_resource(scope)
initialize_resource_class(scope)
return nil unless resource_class
return nil unless data.token_prerequisites_present?
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method validate_redirect_url!
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def validate_redirect_url!(url)
white_list = GrapeTokenAuth.configuration.redirect_whitelist
return unless white_list
url_valid = white_list.include?(url)
error!({ errors: 'redirect url is not in whitelist', status: 'error' }, 403) unless url_valid
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"