Showing 12 of 18 total issues
Method first_unmodifiable_field
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
def first_unmodifiable_field(part, fields)
return (fields.keys.first || '-') unless @access[part]
diff = fields.keys - @access[part].keys
return diff.first if diff.length > 0
- 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 cannot
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def cannot(action, *fields)
action = deprecate_actions(action)
return @destroyable = false if action == :destroy
- 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 protector_defend_graph
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def protector_defend_graph(relation, subject)
return relation unless @opts[:eager_graph]
@opts[:eager_graph][:reflections].each do |association, reflection|
model = reflection[:cache][:class] if reflection[:cache].is_a?(Hash) && reflection[:cache][: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 can
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def can(action, *fields)
action = deprecate_actions(action)
return @destroyable = true if action == :destroy
- 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 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def initialize(adapter, model, fields, subject, entry, blocks)
Method protector_expand_inclusion_hash
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def protector_expand_inclusion_hash(inclusion, results=[], base=[], klass=@klass)
inclusion.each do |key, value|
model = klass.reflect_on_association(key.to_sym).klass
value = [value] unless value.is_a?(Array)
nest = [key] + base
- 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 valid?
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def valid?(*args)
if protector_subject?
state = Protector.insecurely{ super(*args) }
method = new_record? ? :first_uncreatable_field : :first_unupdatable_field
field = protector_meta.send(method, protector_changed)
- 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 too many return
statements within this method. Open
return k if !x.nil? && x != v
Method []
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def [](name)
# rubocop:disable ParenthesesAroundCondition
if (
!protector_subject? ||
name == self.class.primary_key ||
- 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 protector_expand_inclusion
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def protector_expand_inclusion(inclusion, results=[], base=[], klass=@klass)
if inclusion.is_a?(Hash)
protector_expand_inclusion_hash(inclusion, results, base, klass)
else
Array(inclusion).each do |i|
- 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 exec_queries_with_protector
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def exec_queries_with_protector(*args)
return @records if loaded?
return exec_queries_without_protector unless protector_subject?
subject = protector_subject
- 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 run_state
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def run_state(state, color)
data = {}
prof = @profiling
print_block "Protector #{state.send color}" do
- 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"