Showing 14 of 74 total issues
Method select
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def select(keystr = nil, config_name = nil)
prefix = [keystr, config_name].join(' ').strip
regex = /^(?<no>no )?#{Regexp.escape(prefix)} ?(?<data>.+)?/
io = StringIO.open(@nested_config)
- 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 connect
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
def connect
@session = Class.new do
def initialize
@closed = false
end
Method connect
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def connect
Net::SSH.start(@host, @user, @ssh_opts) do |session|
@session = session
@session.open_channel do |channel|
channel.send_channel_request('shell') do |ch, ch_success|
- 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 config_exec
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def config_exec(command, opts = {})
must_be_connected!
enable! if @terminal.prompt =~ EXEC_PROMPT
expect_prompt = opts.fetch(:expect_prompt, CONFIG_PROMPT)
- 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 connect
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def connect
Net::SSH.start(@host, @user, @ssh_opts) do |session|
@session = session
@session.open_channel do |channel|
channel.send_channel_request('shell') do |ch, ch_success|
Method select
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def select(keystr = nil, config_name = nil)
prefix = [keystr, config_name].join(' ').strip
regex = /^(?<no>no )?#{Regexp.escape(prefix)} ?(?<data>.+)?/
io = StringIO.open(@nested_config)
Method version_match_parse
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def self.version_match_parse(expr)
expr = expr.to_s # Forgive users who provide a number instead of a string
m = VERSION_EXPR_REGEX.match(expr)
fail Error::InvalidExpressionError, "Expression '#{expr}' is not valid" unless m
opr = m[:opr]
- 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 expect
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def expect(prompt_regex)
@last_output_received = Time.now.getlocal
while buffer !~ prompt_regex
begin
- 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 running_config
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def running_config(subcmd = nil)
unless @running_config.key? subcmd
output = subcmd ? show('running-config ' + subcmd) : show('running-config')
@running_config[subcmd] = Config.new(nested_config: output)
end
- 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 7 (exceeds 5 allowed). Consider refactoring. Open
def initialize(terminal_opts, enable_password = nil)
@asa = ASAConsole.ssh(terminal_opts)
@asa.enable_password = enable_password if enable_password
@asa.terminal.on_output do |prompt, input, output|
print Test.colorize(prompt, :prompt) if prompt
- 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 disconnect
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def disconnect
while @terminal.connected? && @terminal.prompt =~ ANY_EXEC_PROMPT
@terminal.send('exit', ANY_EXEC_PROMPT) { |success| break unless success }
end
@terminal.disconnect
- 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 names_of
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def names_of(keystr)
names = []
regex = /^(?:no )?#{Regexp.escape(keystr)} (?<name>\S+)/
@nested_config.each_line do |line|
m = regex.match(line)
- 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 version_match_compare
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def self.version_match_compare(opr, ver, pattern)
a = ver[0..(pattern.length - 1)]
b = pattern.clone
eq = true
gt = lt = false
- 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 line
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def line
parts = []
parts << 'no' if @negated
parts << @keystr if @keystr
parts << @config_name if @config_name
- 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"