Method execute
has a Cognitive Complexity of 62 (exceeds 5 allowed). Consider refactoring. Open
def execute(cmd, sudo = false, &stream_block)
results = { exit_status: nil, stdout: '', stderr: '' }
sudo = false if @username == 'root'
if sudo
- 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 execute
has 88 lines of code (exceeds 25 allowed). Consider refactoring. Open
def execute(cmd, sudo = false, &stream_block)
results = { exit_status: nil, stdout: '', stderr: '' }
sudo = false if @username == 'root'
if sudo
Method ssh_connect
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
def ssh_connect
unless @localhost
log = StringIO.new
logger = Logger.new(log)
logger.formatter = proc { |level, date, _progname, msg|
Method ssh_connect
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def ssh_connect
unless @localhost
log = StringIO.new
logger = Logger.new(log)
logger.formatter = proc { |level, date, _progname, msg|
- 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 a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def initialize(hostname, config = {})
@hostname = hostname
@username = if config[:username].nil? || config[:username].strip.empty?
'root'
else
- 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 sudo_stdin
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def sudo_stdin(ch, info, data, sudo_prompt, &stream_block)
Method sudo_stdin
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def sudo_stdin(ch, info, data, sudo_prompt, &stream_block)
# Sudo handling
if data == sudo_prompt
if @sudo_password
ch.send_data "#{@sudo_password}\r\n"
- 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"