Showing 79 of 79 total issues
Method load_token
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def self.load_token(token, request, verbose=true)
token = token.to_s.strip
if DoorMat::Regex.session_guid.match(token).blank?
DoorMat.configuration.logger.warn "WARN: #{request.remote_ip} Attempted to use token with invalid format #{token}" if verbose
return nil
- 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 around_save
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def around_save(record)
return yield if DoorMat::Crypto.current_skip_crypto_callback.skip?
clear_attribute = record.send("#{@attribute}")
actor = record.send("#{@actor_column}")
- 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 with
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def self.with(address, password, request, cookies, controller)
Method add
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def self.add(email, actor, controller)
return false unless email.valid?
actor.with_lock do
return false unless actor.can_add_email? email
- 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 with
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def self.with(address, password, request, cookies, controller)
# Destroy any session linked to existing cookies before
# replacing it by a new session
DoorMat::Session.destroy_if_linked_to(cookies)
- 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 set_primary
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def self.set_primary(encoded_address, actor)
actor.with_lock do
email = actor.email_from_urlsafe_encoded(encoded_address)
return false if email.blank?
- 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
Avoid parameter lists longer than 5 parameters. [7/5] Open
def self.create_from_params(token_for, identifier, confirm_identifier, name, is_public, remember_me, request)
- Read upRead up
- Exclude checks
This cop checks for methods with too many parameters. The maximum number of parameters is configurable. Keyword arguments can optionally be excluded from the total count.
Avoid too many return
statements within this method. Open
return nil
Avoid too many return
statements within this method. Open
return access_token
Avoid too many return
statements within this method. Open
return false
Avoid too many return
statements within this method. Open
return access_token
Avoid too many return
statements within this method. Open
return nil
Method owned_by
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def self.owned_by(owner)
password = DoorMat::Crypto::SymmetricStore.random_key
anonymous_actor = Actor.create_with(password)
return nil if anonymous_actor.blank?
- 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
Avoid parameter lists longer than 5 parameters. [6/5] Open
def self.with(email, password, is_public, remember_me, request, cookies)
- Read upRead up
- Exclude checks
This cop checks for methods with too many parameters. The maximum number of parameters is configurable. Keyword arguments can optionally be excluded from the total count.
Don't use IDs in selectors. Open
#notice {
- Exclude checks
Avoid rescuing the Exception
class. Perhaps you meant to rescue StandardError
? Open
rescue Exception => e
DoorMat.configuration.logger.error "ERROR: CreateNewAnonymousActor failed to with error - #{e}"
nil
- Read upRead up
- Exclude checks
This cop checks for rescue blocks targeting the Exception class.
Example:
# bad
begin
do_something
rescue Exception
handle_exception
end
Example:
# good
begin
do_something
rescue ArgumentError
handle_exception
end
Rule doesn't have all its properties in alphabetical order. Open
#error_explanation {
- Exclude checks
Non-local exit from iterator, without return value. next
, break
, Array#find
, Array#any?
, etc. is preferred. Open
return
- Read upRead up
- Exclude checks
This cop checks for non-local exits from iterators without a return value. It registers an offense under these conditions:
- No value is returned,
- the block is preceded by a method chain,
- the block has arguments,
- the method which receives the block is not
define_method
ordefine_singleton_method
, - the return is not contained in an inner scope, e.g. a lambda or a method definition.
Example:
class ItemApi
rescue_from ValidationError do |e| # non-iteration block with arg
return { message: 'validation error' } unless e.errors # allowed
error_array = e.errors.map do |error| # block with method chain
return if error.suppress? # warned
return "#{error.param}: invalid" unless error.message # allowed
"#{error.param}: #{error.message}"
end
{ message: 'validation error', errors: error_array }
end
def update_items
transaction do # block without arguments
return unless update_necessary? # allowed
find_each do |item| # block without method chain
return if item.stock == 0 # false-negative...
item.update!(foobar: true)
end
end
end
end
Avoid rescuing the Exception
class. Perhaps you meant to rescue StandardError
? Open
rescue Exception => e
DoorMat.configuration.logger.error "ERROR: Failed to change actor password - #{e}"
raise e
- Read upRead up
- Exclude checks
This cop checks for rescue blocks targeting the Exception class.
Example:
# bad
begin
do_something
rescue Exception
handle_exception
end
Example:
# good
begin
do_something
rescue ArgumentError
handle_exception
end
Avoid rescuing the Exception
class. Perhaps you meant to rescue StandardError
? Open
rescue Exception => e
DoorMat.configuration.logger.error "ERROR: Failed to deliver reset password email for actor #{self.actor.id} to #{self.email.address} w #{parameters[:url]} - #{e}"
raise e
- Read upRead up
- Exclude checks
This cop checks for rescue blocks targeting the Exception class.
Example:
# bad
begin
do_something
rescue Exception
handle_exception
end
Example:
# good
begin
do_something
rescue ArgumentError
handle_exception
end