ManageIQ/manageiq-gems-pending

View on GitHub

Showing 218 of 218 total issues

Cyclomatic complexity for convert_type is too high. [13/11]
Open

    def convert_type(c)
      case c.name.to_sym
      when :U16, :U32, :I32, :U64, :I64, :D, :By then c.text.to_i
      when :Db then c.text.to_f
      when :B then c.text.downcase == 'true'

Checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.

An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one. Blocks that are calls to builtin iteration methods (e.g. `ary.map{...}) also add one, others are ignored.

def each_child_node(*types)               # count begins: 1
  unless block_given?                     # unless: +1
    return to_enum(__method__, *types)

  children.each do |child|                # each{}: +1
    next unless child.is_a?(Node)         # unless: +1

    yield child if types.empty? ||        # if: +1, ||: +1
                   types.include?(child.type)
  end

  self
end                                       # total: 6

Cyclomatic complexity for parse_output is too high. [12/11]
Open

  def parse_output(cmd_text)
    last_key = nil
    lines = cmd_text.kind_of?(Array) ? cmd_text : cmd_text.split("\n")
    lines.inject({}) do |a, line|
      idx = line.index(": ")
Severity: Minor
Found in lib/gems/pending/util/miq-ipmi.rb by rubocop

Checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.

An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one. Blocks that are calls to builtin iteration methods (e.g. `ary.map{...}) also add one, others are ignored.

def each_child_node(*types)               # count begins: 1
  unless block_given?                     # unless: +1
    return to_enum(__method__, *types)

  children.each do |child|                # each{}: +1
    next unless child.is_a?(Node)         # unless: +1

    yield child if types.empty? ||        # if: +1, ||: +1
                   types.include?(child.type)
  end

  self
end                                       # total: 6

Cyclomatic complexity for miq_patch_elements is too high. [12/11]
Open

  def miq_patch_elements(xml, patch, node, direction, stats)
    miq_patch_element_logging(node, direction)
    patch.root.elements[node.to_s].each_element do |e|
      path = e.elements['path'].elements[1]
      data = e.elements['data'].elements[1]

Checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.

An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one. Blocks that are calls to builtin iteration methods (e.g. `ary.map{...}) also add one, others are ignored.

def each_child_node(*types)               # count begins: 1
  unless block_given?                     # unless: +1
    return to_enum(__method__, *types)

  children.each do |child|                # each{}: +1
    next unless child.is_a?(Node)         # unless: +1

    yield child if types.empty? ||        # if: +1, ||: +1
                   types.include?(child.type)
  end

  self
end                                       # total: 6

Method initialize has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    def initialize(first, second = nil, parent = nil)
      @normalized = @unnormalized = @element = nil
      if first.kind_of? Attribute
        self.name = first.expanded_name
        @value = first.value
Severity: Minor
Found in lib/gems/pending/util/xml/miq_rexml.rb - About 1 hr to fix

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_record_change has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

  def miq_record_change(node, _delta, diff_elements, stats)
    srcPath = node[0].nil? ? node[1] : node[0]

    if node[1].nil?
      action = :adds
Severity: Minor
Found in lib/gems/pending/util/xml/xml_diff.rb - About 1 hr to fix

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 cpu_usage has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

  def self.cpu_usage
    if Sys::Platform::IMPL == :linux
      filename = "/var/www/miq/vmdb/log/vmstat_output.log"

      begin
Severity: Minor
Found in lib/gems/pending/util/miq-system.rb - About 1 hr to fix

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 verify has 38 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def verify
    log_header = "MIQ(#{self.class.name}-verify)"
    logger.info("#{log_header} [#{@settings[:uri]}]...")
    res = true

Severity: Minor
Found in lib/gems/pending/util/mount/miq_generic_mount_session.rb - About 1 hr to fix

Method miq_patch_elements has 37 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def miq_patch_elements(xml, patch, node, direction, stats)
    miq_patch_element_logging(node, direction)
    patch.root.elements[node.to_s].each_element do |e|
      path = e.elements['path'].elements[1]
      data = e.elements['data'].elements[1]
Severity: Minor
Found in lib/gems/pending/util/xml/xml_patch.rb - About 1 hr to fix

Method findRegElementInt has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

  def self.findRegElementInt(paths, ele)
    if paths.length > 0
      searchStr = paths[0].downcase
      paths = paths[1..paths.length]
      # puts "Search String: #{searchStr}"
Severity: Minor
Found in lib/gems/pending/util/xml/miq_rexml.rb - About 1 hr to fix

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 findRegElementInt has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    def self.findRegElementInt(paths, ele)
      if paths.length > 0
        searchStr = paths[0].downcase
        paths = paths[1..paths.length]
        # puts "Search String: #{searchStr}"
Severity: Minor
Found in lib/gems/pending/util/xml/xml_hash.rb - About 1 hr to fix

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_diff_element2 has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

  def miq_find_diff_element2(searchNode, xml)
    # Loop over each element to find matching elements at the current level
    xml.each_element do |dataNode|
      comp_rc = miq_same_element(searchNode, dataNode)
      if comp_rc.zero?
Severity: Minor
Found in lib/gems/pending/util/xml/xml_patch.rb - About 1 hr to fix

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 processInfo has 34 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def self.processInfo(pid = nil)
    pid ||= Process.pid

    result = {:pid => pid}

Severity: Minor
Found in lib/gems/pending/util/miq-process.rb - About 1 hr to fix

Method disconnect has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

  def self.disconnect(mnt_point, logger = $log)
    return if mnt_point.nil?
    log_header = "MIQ(#{self.class.name}-disconnect)"
    logger.info("#{log_header} Disconnecting mount point: #{mnt_point}") if logger
    begin
Severity: Minor
Found in lib/gems/pending/util/mount/miq_generic_mount_session.rb - About 1 hr to fix

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 runProcess has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

  def runProcess(command, async = true, startup = {})
    startup = {:ShowWindow => 1, :Title => "MIQ - #{Time.now.utc.iso8601}"}.merge(startup)
    objStartup = @objWMI.Get("Win32_ProcessStartup").SpawnInstance_
    startup.each_pair { |k, v| objStartup.send("#{k}=", v) }

Severity: Minor
Found in lib/gems/pending/util/win32/miq-wmi-mswin.rb - About 1 hr to fix

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 _key_type= has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

  def _key_type=(value)
    raise ArgumentError, "key type must be Symbol or String" unless [Symbol, String].include?(value)

    unless @key_type == value
      m = (value == String) ? :to_s : :to_sym
Severity: Minor
Found in lib/gems/pending/util/miq-hash_struct.rb - About 1 hr to fix

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 to_h_simple has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    def to_h_simple(options, hash = nil)
      hash = {} if hash.nil?

      each do |c|
        e = (hash[options[:symbols] == false ? c.name.to_s : c.name] ||= []) << (options[:symbols] == false ? c.attributes&.stringify_keys : c.attributes)
Severity: Minor
Found in lib/gems/pending/util/xml/xml_hash.rb - About 1 hr to fix

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 split_raw_line has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

  def self.split_raw_line(line)
    line = line.to_s
    return if line.empty?

    time = line[11, 26]
Severity: Minor
Found in lib/gems/pending/util/miq_logger_processor.rb - About 1 hr to fix

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 to_png has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def self.to_png(data, options = {})
    require 'gruff'

    graph = case options[:graph_type]
            when :line    then Gruff::Line.new
Severity: Minor
Found in lib/gems/pending/util/miq_logger_processor.rb - About 1 hr to fix

Method walk has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def self.walk(node, parents = "")
    tags = []

    sep = "/"
    case node.name
Severity: Minor
Found in lib/gems/pending/util/xml/xml_utils.rb - About 1 hr to fix

Method miq_record_change has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def miq_record_change(node, _delta, diff_elements, stats)
    srcPath = node[0].nil? ? node[1] : node[0]

    if node[1].nil?
      action = :adds
Severity: Minor
Found in lib/gems/pending/util/xml/xml_diff.rb - About 1 hr to fix
Severity
Category
Status
Source
Language