Showing 218 of 218 total issues
Method read_single_chunk
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def read_single_chunk(chunksize = DEFAULT_CHUNKSIZE)
@buf_left ||= byte_count
return DONE_READING.dup unless @buf_left.nil? || @buf_left.positive?
cur_readsize = if @buf_left.nil? || @buf_left - chunksize >= 0
chunksize
- Read upRead up
- Create a ticketCreate a ticket
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 get_windows_version
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def get_windows_version
stdout_text = ""
stderr_text = ""
command_line = "winexe -U #{@server}/#{@username} //#{@server} \"cmd\""
Open3.popen3(command_line) do |stdin, stdout, stderr|
- Read upRead up
- Create a ticketCreate a ticket
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 process_named_elements
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def process_named_elements(node)
hsh = {}
node.each_element do |e|
name = e.attributes['N']
name = name.value if name.respond_to?(:value)
- Read upRead up
- Create a ticketCreate a ticket
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 []
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def [](index, _name = nil)
if index.kind_of? Integer
raise "index (#{index}) must be >= 1" if index < 1
return @element.children[index - 1]
else
- Read upRead up
- Create a ticketCreate a ticket
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 memory
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def self.memory
result = {}
case Sys::Platform::IMPL
when :mswin, :mingw
# raise "MiqSystem.memory: Windows Not Supported"
- Read upRead up
- Create a ticketCreate a ticket
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 parameter lists longer than 5 parameters. [9/5] Open
def miq_patch_process_element(ele, data, path, compare_roots, direction, parent_node, node, xml, stats)
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
Checks for methods with too many parameters.
The maximum number of parameters is configurable. Keyword arguments can optionally be excluded from the total count, as they add less complexity than positional or optional parameters.
Any number of arguments for initialize
method inside a block of
Struct.new
and Data.define
like this is always allowed:
Struct.new(:one, :two, :three, :four, :five, keyword_init: true) do
def initialize(one:, two:, three:, four:, five:)
end
end
This is because checking the number of arguments of the initialize
method
does not make sense.
NOTE: Explicit block argument &block
is not counted to prevent
erroneous change that is avoided by making block argument implicit.
Example: Max: 3
# good
def foo(a, b, c = 1)
end
Example: Max: 2
# bad
def foo(a, b, c = 1)
end
Example: CountKeywordArgs: true (default)
# counts keyword args towards the maximum
# bad (assuming Max is 3)
def foo(a, b, c, d: 1)
end
# good (assuming Max is 3)
def foo(a, b, c: 1)
end
Example: CountKeywordArgs: false
# don't count keyword args towards the maximum
# good (assuming Max is 3)
def foo(a, b, c, d: 1)
end
This cop also checks for the maximum number of optional parameters.
This can be configured using the MaxOptionalParameters
config option.
Example: MaxOptionalParameters: 3 (default)
# good
def foo(a = 1, b = 2, c = 3)
end
Example: MaxOptionalParameters: 2
# bad
def foo(a = 1, b = 2, c = 3)
end
Method miq_compare_roots
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def miq_compare_roots(node1, xml2, delta, diff_elements, stats)
- Create a ticketCreate a ticket
Method log_require
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def log_require(path, mode, timing = nil, memory_consumed = nil, features_loaded = nil)
- Create a ticketCreate a ticket
Method miq_patch_elements
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def miq_patch_elements(xml, patch, node, direction, stats)
- Create a ticketCreate a ticket
Method miq_patch_update_element
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def miq_patch_update_element(element, data, compare_roots, direction, stats)
- Create a ticketCreate a ticket
Method each_element_with_attribute
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def each_element_with_attribute(key, value = nil, max = 0, _name = nil, &_block) # :yields: Element
- Create a ticketCreate a ticket
Method miq_compare_elements
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def miq_compare_elements(node1, node2, delta, diff_elements, stats)
- Create a ticketCreate a ticket
Method write
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def write(output = $stdout, indent = -1, transitive = false, ie_hack = false)
return write_orig(output, indent, transitive, ie_hack) unless defined?(REXML::Formatters)
formatter = if indent > -1
if transitive
REXML::Formatters::Transitive.new(indent, ie_hack)
- Read upRead up
- Create a ticketCreate a ticket
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 require
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def require(path) # :doc:
with_require_logging(path) { gem_original_require(path) }
rescue LoadError => load_error
if load_error.message =~ /#{Regexp.escape path}\z/ &&
spec = Gem.searcher.find(path)
- Read upRead up
- Create a ticketCreate a ticket
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 miq_compare_attributes
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def miq_compare_attributes(e1, e2)
# If the attribute count does not match, they can't be equal
return false if e1.attributes.length != e2.attributes.length
# Next check the element text (use to_s to convert nil to "")
- Read upRead up
- Create a ticketCreate a ticket
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 tripped?
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def tripped?(entry)
if entry.dup_count < duplicate_threshold
reset(entry) if entry.blocked_count > 0
return false
end
- Read upRead up
- Create a ticketCreate a ticket
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 add_elements_from_xml
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def add_elements_from_xml(xml)
xml.each_element do |e|
xmh = add_element(e.name)
e.attributes.each_pair { |k, v| xmh.add_attribute(k, v.to_s) }
if e.cdatas.empty?
- Read upRead up
- Create a ticketCreate a ticket
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 miq_find_element
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def miq_find_element(e, node)
return nil unless node
found = nil
node.each_element do|e2|
found = e2 if miq_same_element(e, e2) == 0
- Read upRead up
- Create a ticketCreate a ticket
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 load
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def self.load(data)
REXML::Document.new(data)
rescue => err
if err.class == ::Encoding::CompatibilityError
data_utf8 = data.dup.force_encoding('UTF-8')
- Read upRead up
- Create a ticketCreate a ticket
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 pingable?
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def pingable?
log_header = "MIQ(#{self.class.name}-pingable?)"
return true unless self.do_ping?
return true unless @settings[:ports].kind_of?(Array)
- Read upRead up
- Create a ticketCreate a ticket
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"