ManageIQ/manageiq

View on GitHub

Showing 286 of 1,314 total issues

Method rss_fails_policy has a Cognitive Complexity of 13 (exceeds 11 allowed). Consider refactoring.
Open

  def self.rss_fails_policy(_name, options)
    order(options[:orderby]).limit(options[:limit_to_count]).each_with_object([]) do |vm, result|
      rec = OpenStruct.new(vm.attributes)
      if vm.host.nil?
        rec.host_name = "unknown"
Severity: Minor
Found in app/models/vm_or_template.rb - About 35 mins 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 queue_refresh has a Cognitive Complexity of 13 (exceeds 11 allowed). Consider refactoring.
Open

  def self.queue_refresh(target, id = nil, opts = {})
    # Handle targets passed as a single class/id pair, an array of class/id pairs, or an array of references
    targets = get_target_objects(target, id)

    # Group the target refs by zone and role
Severity: Minor
Found in app/models/ems_refresh.rb - About 35 mins 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_export_xml has a Cognitive Complexity of 13 (exceeds 11 allowed). Consider refactoring.
Open

  def to_export_xml(options = {})
    require 'builder'
    xml = options[:builder] ||= ::Builder::XmlMarkup.new(:indent => options[:indent])
    xml_attrs = {:name => name, :namespace => namespace}

Severity: Minor
Found in app/models/miq_ae_class.rb - About 35 mins 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 set_ws_field_value has a Cognitive Complexity of 13 (exceeds 11 allowed). Consider refactoring.
Open

  def set_ws_field_value(values, key, data, dialog_name, dlg_fields)
    value = data.delete(key)

    dlg_field = dlg_fields[key]
    data_type = dlg_field[:data_type]
Severity: Minor
Found in app/models/miq_request_workflow.rb - About 35 mins 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_human has a Cognitive Complexity of 13 (exceeds 11 allowed). Consider refactoring.
Open

  def self.to_human(exp)
    if exp.kind_of?(self)
      exp.to_human
    elsif exp.kind_of?(Hash)
      case exp["mode"]
Severity: Minor
Found in lib/miq_expression.rb - About 35 mins 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_storage_files_to_vms has a Cognitive Complexity of 12 (exceeds 11 allowed). Consider refactoring.
Open

  def self.link_storage_files_to_vms(files, vm_ids_by_path, update = true)
    return if vm_ids_by_path.blank?

    files = [files] unless files.kind_of?(Array)
    files.each do |f|
Severity: Minor
Found in app/models/storage_file.rb - About 25 mins 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 groups_for has a Cognitive Complexity of 12 (exceeds 11 allowed). Consider refactoring.
Open

    def groups_for(obj)
      authentication = config.dup
      authentication[:group_memberships_max_depth] ||= DEFAULT_GROUP_MEMBERSHIPS_MAX_DEPTH

      if authentication.key?(:user_proxies) && authentication[:user_proxies].present? && authentication.key?(:get_direct_groups) && authentication[:get_direct_groups] == false
Severity: Minor
Found in app/models/authenticator/ldap.rb - About 25 mins 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 find_entry_by_keys has a Cognitive Complexity of 12 (exceeds 11 allowed). Consider refactoring.
Open

  def self.find_entry_by_keys(klass, keys)
    keys2array = keys
    primary_key, primary_key_value = keys2array.shift
    result = klass.where(klass.arel_table[primary_key.to_sym].lower.eq(primary_key_value.downcase))
    return result if result.size <= 1
Severity: Minor
Found in app/models/miq_bulk_import.rb - About 25 mins 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 authorized_for_user? has a Cognitive Complexity of 12 (exceeds 11 allowed). Consider refactoring.
Open

  def authorized_for_user?(userid)
    user     = User.lookup_by_userid(userid)
    mfilters = user ? user.get_managed_filters : []
    bfilters = user ? user.get_belongsto_filters : []
    db       = self.class
Severity: Minor
Found in app/models/mixins/filterable_mixin.rb - About 25 mins 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 invoke_tasks_remote has a Cognitive Complexity of 12 (exceeds 11 allowed). Consider refactoring.
Open

    def invoke_tasks_remote(options)
      ApplicationRecord.group_ids_by_region(options[:ids]).each do |region, ids|
        remote_options = options.merge(:ids => ids)

        begin
Severity: Minor
Found in app/models/mixins/process_tasks_mixin.rb - About 25 mins 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 partition_group_and_level_by_event_type has a Cognitive Complexity of 12 (exceeds 11 allowed). Consider refactoring.
Open

  private_class_method def self.partition_group_and_level_by_event_type
    return @literal_group_and_level_by_event_type, @regex_group_and_level_by_event_type if @literal_group_and_level_by_event_type

    @literal_group_and_level_by_event_type = {}
    @regex_group_and_level_by_event_type = {}
Severity: Minor
Found in app/models/ems_event.rb - About 25 mins 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 v_calc_pct_of_cpu_time has a Cognitive Complexity of 12 (exceeds 11 allowed). Consider refactoring.
Open

  def v_calc_pct_of_cpu_time(vcol)
    col = vcol.to_s.split("_")[2..-1].join("_")
    return nil if send(col).nil?

    int, default_intervals_in_rollup = CHILD_ROLLUP_INTERVAL[capture_interval_name]
Severity: Minor
Found in app/models/metric/common.rb - About 25 mins 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_sort_suffix_data has a Cognitive Complexity of 12 (exceeds 11 allowed). Consider refactoring.
Open

  def build_sort_suffix_data
    new_sortby = []
    rpt_sortby = Array.wrap(sortby)
    rpt_sortby.each do |sb|
      col, sfx = sb.split("__")
Severity: Minor
Found in app/models/miq_report/generator/sorting.rb - About 25 mins 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 handle_attributes has a Cognitive Complexity of 12 (exceeds 11 allowed). Consider refactoring.
Open

  def handle_attributes(export_attributes)
    if export_attributes['resource_type'] == 'MiqReport' || export_attributes['resource_type'] == 'MiqWidget'
      filter_record_id = export_attributes['filter'].exp["="]["value"]
      resource = export_attributes["resource_type"].safe_constantize.find_by(:id => filter_record_id)
      export_attributes["filter_resource_name"] = export_attributes["resource_type"] == "MiqReport" ? resource.name : resource.description if resource
Severity: Minor
Found in app/models/miq_schedule/import_export.rb - About 25 mins 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 report_row_key has a Cognitive Complexity of 12 (exceeds 11 allowed). Consider refactoring.
Open

  def self.report_row_key(consumption)
    ts_key = @options.start_of_report_step(consumption.timestamp)
    if @options[:groupby_tag].present?
      classifications = @options.classification_for(consumption)
      if classifications.present?
Severity: Minor
Found in app/models/chargeback.rb - About 25 mins 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 activate_in_region has a Cognitive Complexity of 12 (exceeds 11 allowed). Consider refactoring.
Open

  def activate_in_region(override = false)
    return unless server_role.role_scope == 'region'

    if override || inactive?
      MiqRegion.my_region.lock do
Severity: Minor
Found in app/models/assigned_server_role.rb - About 25 mins 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 find_or_create_by_contents has a Cognitive Complexity of 12 (exceeds 11 allowed). Consider refactoring.
Open

  def self.find_or_create_by_contents(hashes)
    hashes = [hashes] unless hashes.kind_of?(Array)
    md5s = []
    hashes = hashes.reject do |hash|
      if hash[:draft]
Severity: Minor
Found in app/models/orchestration_template.rb - About 25 mins 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 invoke_or_queue has a Cognitive Complexity of 12 (exceeds 11 allowed). Consider refactoring.
Open

  def invoke_or_queue(
    synchronous,
    calling_method,
    role,
    zone,
Severity: Minor
Found in app/models/miq_action.rb - About 25 mins 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 embedded_resource_limit_exceeded? has a Cognitive Complexity of 12 (exceeds 11 allowed). Consider refactoring.
Open

    def embedded_resource_limit_exceeded?(job)
      return false unless job.target_class == "VmOrTemplate"

      if @vm.nil?
        job.signal(:abort, "Unable to find vm [#{job.target_id}], aborting job [#{job.guid}].", "error")
Severity: Minor
Found in app/models/vm_scan/dispatcher.rb - About 25 mins 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 transform_parameters_row_with_all_metrics has a Cognitive Complexity of 12 (exceeds 11 allowed). Consider refactoring.
Open

  def transform_parameters_row_with_all_metrics(resources, interval_name, start_time, end_time, rt_rows)
    obj_perfs, = Benchmark.realtime_block(:db_find_prev_perfs) do
      Metric::Finders.find_all_by_range(resources, start_time, end_time, interval_name).find_each.each_with_object({}) do |p, h|
        data, = Benchmark.realtime_block(:get_attributes) do
          # TODO(lsmola) calling .attributes takes more time than actually saving all the samples, try to fetch pure
Severity: Minor
Found in app/models/metric/ci_mixin/processing.rb - About 25 mins 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