Method run
has a Cognitive Complexity of 129 (exceeds 5 allowed). Consider refactoring. Open
def run
@show_progress = datastore['ShowProgress']
@show_percent = datastore['ShowProgressPercent'].to_i
if self.respond_to?(:session) && session
- 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
has 160 lines of code (exceeds 25 allowed). Consider refactoring. Open
def run
@show_progress = datastore['ShowProgress']
@show_percent = datastore['ShowProgressPercent'].to_i
if self.respond_to?(:session) && session
File scanner.rb
has 255 lines of code (exceeds 250 allowed). Consider refactoring. Open
module Msf
###
#
# This module provides methods for scanning modules
Method add_delay_jitter
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def add_delay_jitter(_delay, _jitter)
# Introduce the delay
delay_value = _delay.to_i
original_value = delay_value
jitter_value = _jitter.to_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
Avoid deeply nested control flow statements. Open
if (not datastore)
nohosts = true
break
end
Avoid deeply nested control flow statements. Open
rescue ::Exception => e
print_status("Error: #{mybatch[0]}-#{mybatch[-1]}: #{e}")
Avoid deeply nested control flow statements. Open
rescue StopIteration
datastore = nil
Avoid deeply nested control flow statements. Open
rescue ::Interrupt,::NoMethodError, ::RuntimeError, ::ArgumentError, ::NameError
raise $!
Avoid deeply nested control flow statements. Open
rescue ::Rex::BindFailed
if datastore['CHOST']
@scan_errors << "The source IP (CHOST) value of #{datastore['CHOST']} was not usable"
end
Avoid deeply nested control flow statements. Open
rescue ::Rex::ConnectionError, ::Rex::ConnectionProxyError, ::Errno::ECONNRESET, ::Errno::EINTR, ::Rex::TimeoutError, ::Timeout::Error
Avoid deeply nested control flow statements. Open
rescue Msf::Auxiliary::Scanner::AttemptFailed => e
print_error("#{e}")
Method scanner_handle_fatal_errors
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def scanner_handle_fatal_errors
return unless has_fatal_errors?
return unless @thread_list
# First kill any running threads
- 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"