Assignment Branch Condition size for run is too high. [20.42/15] Open
def run
return false unless super
emit_info 'Creating new admin user...'
res = execute_post_request(
- Read upRead up
- Exclude checks
This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric
Method initialize
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def initialize
super
update_info(
name: 'Download Manager Privilege Escalation',
Method run
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def run
return false unless super
emit_info 'Creating new admin user...'
res = execute_post_request(
Avoid too many return
statements within this method. Open
return true
Method run
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def run
return false unless super
emit_info 'Creating new admin user...'
res = execute_post_request(
- 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
Unreachable code detected. Open
if res.nil? || res.timed_out?
emit_error 'No response from the target'
return false
end
- Read upRead up
- Exclude checks
This cop checks for unreachable code. The check are based on the presence of flow of control statement in non-final position in begin(implicit) blocks.
Example:
# bad
def some_method
return
do_something
end
# bad
def some_method
if cond
return
else
return
end
do_something
end
Example:
# good
def some_method
do_something
end
Redundant return
detected. Open
return true
- Read upRead up
- Exclude checks
This cop checks for redundant return
expressions.
Example:
def test
return something
end
def test
one
two
three
return something
end
It should be extended to handle methods whose body is if/else or a case expression with a default branch.