Showing 6 of 10 total issues
Method find
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def find
if object.nil?
nil
elsif controller.respond_to?(:policy_class)
controller.policy_class
- 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
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def find
if object.nil?
nil
elsif controller.respond_to?(:policy_class)
controller.policy_class
Method initialize
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def initialize(object, controller_or_namespace = nil)
@object = object
if controller_or_namespace.instance_of? Module
# Its a Module
- 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 format_action
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def format_action(action, subject)
# https://github.com/elabs/regulator/blob/master/lib/generators/regulator/install/templates/application_policy.rb
case action
when ActiveAdmin::Auth::CREATE then :create?
when ActiveAdmin::Auth::UPDATE then :update?
- 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 format_action
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def format_action(action, subject)
# https://github.com/elabs/regulator/blob/master/lib/generators/regulator/install/templates/application_policy.rb
case action
when Auth::CREATE then :create?
when Auth::UPDATE then :update?
- 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 retrieve_policy
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def retrieve_policy(subject)
case subject
when nil then Regulator.policy!(user, resource, regulator_policy_namespace)
when Class then Regulator.policy!(user, subject.new, regulator_policy_namespace)
else Regulator.policy!(user, subject, regulator_policy_namespace)
- 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"