ManageIQ/manageiq

View on GitHub

Showing 1,024 of 1,024 total issues

Method scan_from_queue has a Cognitive Complexity of 86 (exceeds 11 allowed). Consider refactoring.
Open

  def scan_from_queue(taskid = nil)
    unless taskid.nil?
      task = MiqTask.find_by(:id => taskid)
      task.state_active if task
    end
Severity: Minor
Found in app/models/host.rb - About 1 day 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 link_ems_inventory has a Cognitive Complexity of 77 (exceeds 11 allowed). Consider refactoring.
Open

  def link_ems_inventory(ems, target, prev_relats, new_relats, disconnect = true)
    log_header = "EMS: [#{ems.name}], id: [#{ems.id}]"
    _log.info("#{log_header} Linking EMS Inventory...")
    _log.debug("#{log_header} prev_relats: #{prev_relats.inspect}")
    _log.debug("#{log_header} new_relats:  #{new_relats.inspect}")
Severity: Minor
Found in app/models/ems_refresh/link_inventory.rb - About 1 day 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 performances_maintains_value_for_duration? has a Cognitive Complexity of 72 (exceeds 11 allowed). Consider refactoring.
Open

  def performances_maintains_value_for_duration?(options)
    _log.info("options: #{options.inspect}")
    raise _("Argument must be an options hash") unless options.kind_of?(Hash)
    column = options[:column]
    value = options[:value].to_f
Severity: Minor
Found in app/models/metric/ci_mixin.rb - About 1 day 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 action_snmp_trap has a Cognitive Complexity of 71 (exceeds 11 allowed). Consider refactoring.
Open

  def action_snmp_trap(action, rec, inputs)
    # Validate SNMP Version
    snmp_version = action.options[:snmp_version]
    snmp_version = 2 if action.options[:snmp_version] == "v2"
    snmp_version = 1 if action.options[:snmp_version] == "v1"
Severity: Minor
Found in app/models/miq_action.rb - About 1 day 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 process_derived_columns has a Cognitive Complexity of 68 (exceeds 11 allowed). Consider refactoring.
Open

  def self.process_derived_columns(obj, attrs, ts = nil)
    unless VALID_PROCESS_TARGETS.any? { |t| obj.kind_of?(t) }
      raise _("object %{name} is not one of %{items}") % {:name  => obj,
                                                          :items => VALID_PROCESS_TARGETS.collect(&:name).join(", ")}
    end
Severity: Minor
Found in app/models/metric/processing.rb - About 1 day 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 save_vms_inventory has a Cognitive Complexity of 68 (exceeds 11 allowed). Consider refactoring.
Open

  def save_vms_inventory(ems, hashes, target = nil, disconnect = true)
    return if hashes.nil?
    target = ems if target.nil? && disconnect
    log_header = "EMS: [#{ems.name}], id: [#{ems.id}]"

Severity: Minor
Found in app/models/ems_refresh/save_inventory.rb - About 1 day 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 validate has a Cognitive Complexity of 60 (exceeds 11 allowed). Consider refactoring.
Open

  def validate(values)
    # => Input - A hash keyed by field name with entered values
    # => Output - true || false
    #
    # Update @dialogs adding error keys to fields that don't validate
Severity: Minor
Found in app/models/miq_request_workflow.rb - About 1 day 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 dispatch has a Cognitive Complexity of 57 (exceeds 11 allowed). Consider refactoring.
Open

  def dispatch
    _dummy, t = Benchmark.realtime_block(:total_time) do
      Benchmark.realtime_block(:v2v_dispatching) { dispatch_v2v_migrations }
      Benchmark.realtime_block(:v2v_limits) { apply_v2v_limits }
      Benchmark.realtime_block(:container_dispatching) { dispatch_container_scan_jobs }
Severity: Minor
Found in app/models/job_proxy_dispatcher.rb - About 7 hrs 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 process_data has a Cognitive Complexity of 57 (exceeds 11 allowed). Consider refactoring.
Open

  def process_data(*args)
    _log.info("starting...")

    data = args.first
    set_status("Processing VM data")
Severity: Minor
Found in app/models/vm_scan.rb - About 7 hrs 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 fetch_record_section has a Cognitive Complexity of 56 (exceeds 11 allowed). Consider refactoring.
Open

  def fetch_record_section(id, section, sub_sections, columns)
    section = section[:name]
    result_section = @results[id][section] = {}
    rec = find_record(id)

Severity: Minor
Found in app/models/miq_compare.rb - About 7 hrs 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 build_html_rows has a Cognitive Complexity of 55 (exceeds 11 allowed). Consider refactoring.
Open

  def build_html_rows(clickable_rows = false)
    time_zone = get_time_zone(Time.zone)
    html_rows = []
    group_counter = 0
    row = 0
Severity: Minor
Found in app/models/miq_report/generator/html.rb - About 7 hrs 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 vmdb_relats_ems has a Cognitive Complexity of 55 (exceeds 11 allowed). Consider refactoring.
Open

  def vmdb_relats_ems(ems, relats = nil)
    # Use a more optimized vmdb search than following the ancestors and descendants
    relats ||= default_relats_hash
    ems.with_relationship_type('ems_metadata') do
      metadata_type_to_meth = Hash.new { |_h, k| k }.merge(:folders => :ems_folders, :clusters => :ems_clusters)
Severity: Minor
Found in app/models/ems_refresh/metadata_relats.rb - About 7 hrs 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 atom_error has a Cognitive Complexity of 55 (exceeds 11 allowed). Consider refactoring.
Open

  def self.atom_error(field, operator, value)
    return false if operator == "DEFAULT" # No validation needed for style DEFAULT operator

    value = value.to_s unless value.kind_of?(Array)

Severity: Minor
Found in lib/miq_expression.rb - About 7 hrs 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 xml_to_hashes has a Cognitive Complexity of 53 (exceeds 11 allowed). Consider refactoring.
Open

  def self.xml_to_hashes(xmlNode, vm_or_template_id)
    return nil unless MiqXml.isXmlElement?(xmlNode)

    all_nh = []

Severity: Minor
Found in app/models/snapshot.rb - About 7 hrs 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 search has a Cognitive Complexity of 53 (exceeds 11 allowed). Consider refactoring.
Open

    def search(options = {})
      if options.key?(:targets) && options[:targets].kind_of?(Array) && options[:targets].empty?
        return [], {:auth_count => 0}
      end
      # => empty inputs - normal find with optional where_clause
Severity: Minor
Found in lib/rbac/filterer.rb - About 7 hrs 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 perf_capture_queue has a Cognitive Complexity of 50 (exceeds 11 allowed). Consider refactoring.
Open

  def perf_capture_queue(interval_name, options = {})
    start_time = options[:start_time]
    end_time   = options[:end_time]
    priority   = options[:priority] || Metric::Capture.const_get("#{interval_name.upcase}_PRIORITY")
    task_id    = options[:task_id]
Severity: Minor
Found in app/models/metric/ci_mixin/capture.rb - About 6 hrs 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 build_add_includes has a Cognitive Complexity of 49 (exceeds 11 allowed). Consider refactoring.
Open

  def build_add_includes(data_records, entry, includes, parent_association)
    include_has_options = includes.kind_of?(Hash)
    associations = include_has_options ? includes.keys : Array(includes)

    associations.each do |association|
Severity: Minor
Found in app/models/miq_report/generator.rb - About 6 hrs 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 process_hourly_for_one_day has a Cognitive Complexity of 46 (exceeds 11 allowed). Consider refactoring.
Open

  def self.process_hourly_for_one_day(recs, options = {})
    only_cols = process_only_cols(recs)
    result = {}
    counts = {}

Severity: Minor
Found in app/models/vim_performance_daily.rb - About 6 hrs 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

Cyclomatic complexity for performances_maintains_value_for_duration? is too high. [48/11]
Open

  def performances_maintains_value_for_duration?(options)
    _log.info("options: #{options.inspect}")
    raise _("Argument must be an options hash") unless options.kind_of?(Hash)
    column = options[:column]
    value = options[:value].to_f
Severity: Minor
Found in app/models/metric/ci_mixin.rb by rubocop

This cop 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.

Method build_for_association has a Cognitive Complexity of 45 (exceeds 11 allowed). Consider refactoring.
Open

  def self.build_for_association(parent_perf, assoc, options = {})
    eligible_cats = eligible_categories
    return [] if eligible_cats.empty?

    ts = parent_perf.timestamp
Severity: Minor
Found in app/models/vim_performance_tag_value.rb - About 5 hrs 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

Severity
Category
Status
Source
Language