ManageIQ/manageiq-providers-openstack

View on GitHub

Showing 16 of 190 total issues

Method parse_file_attributes has a Cognitive Complexity of 47 (exceeds 11 allowed). Consider refactoring.
Open

  def parse_file_attributes(file)
    # Functionality of python's ConfigParser, extended with parsing of the descriptions, specific to OpenStack config
    # files and specific OpenStack interpolation. Also only '=' is allowed as key/value delimiter and keys has to be
    # in snake case strictly matched by \w. As it is strict format used by openstack config files.
    attributes_hash = {}

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

  def process_multi_counter_stats!(counter_values_by_ts, metric_capture_module, i, timestamps, metrics_by_counter_name,
                                   data_collecting_period, log_header)
    # !!! This method modifies counter_values_by_ts
    # We have more counters in calculation. We have to make sure all counters have values present. It can
    # happen that data of related counters are not collected in the same 20s window. So we will try to collect
Severity: Minor
Found in app/models/manageiq/providers/openstack/base_metrics_capture.rb - About 4 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 create_or_find_miq_group_and_add_user has a Cognitive Complexity of 23 (exceeds 11 allowed). Consider refactoring.
Open

  def create_or_find_miq_group_and_add_user(user, tenant, role_name)
    # Find MiqGroup corresponding to this role and project/tenant
    # create one if it doesn't exist
    # add user to the MiqGroup
    admin_role_id = ext_management_system.miq_custom_get(IDENTITY_SYNC_ADMIN_ROLE_ID_NEW)
Severity: Minor
Found in app/models/manageiq/providers/openstack/identity_sync_mixin.rb - About 2 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 accessor_for_accessible_tenants has a Cognitive Complexity of 23 (exceeds 11 allowed). Consider refactoring.
Open

    def accessor_for_accessible_tenants(service, accessor, unique_id, array_accessor = true)
      results = []
      not_found_error = Fog::OpenStack.const_get(service)::NotFound
      ::Parallel.each(service_for_each_accessible_tenant(service), :in_threads => thread_limit) do |svc, project|

Severity: Minor
Found in lib/manageiq/providers/openstack/legacy/openstack_handle/handle.rb - About 2 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 each_batch has a Cognitive Complexity of 22 (exceeds 11 allowed). Consider refactoring.
Open

  def each_batch
    while @monitor_events
      $log.info("Querying OpenStack for events newer than #{latest_event_timestamp}...") if $log
      events = list_events(query_options).sort_by(&:generated)

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

  def parse_vm(vm, hosts)
    if hosts && vm.os_ext_srv_attr_host.present?
      parent_host = hosts.find_by('lower(hypervisor_hostname) = ? OR lower(hypervisor_hostname) = ?', vm.os_ext_srv_attr_host.split('.').first.downcase, vm.os_ext_srv_attr_host.downcase)
      parent_cluster = parent_host.try(:ems_cluster)
    else

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

  def call_snapshot_delete
    _log.info("Enter")

    # TODO: remove snapshot here if Vm was running
    if context[:snapshot_mor]

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

  def prepare_volumes_fields(values)
    # the provision dialog doesn't handle arrays,
    # so we have to hack around it to support an arbitrary
    # number of volumes being added at once.
    # This looks for volume form fields in the input, and converts

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

  def refresh_network_interfaces(ssu)
    smartstate_network_ports = MiqLinux::Utils.parse_network_interface_list(ssu.shell_exec("ip a"))

    neutron_network_ports = network_ports.where(:source => :refresh).each_with_object({}) do |network_port, obj|
      obj[network_port.mac_address] = network_port
Severity: Minor
Found in app/models/manageiq/providers/openstack/infra_manager/host.rb - About 55 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 connect has a Cognitive Complexity of 13 (exceeds 11 allowed). Consider refactoring.
Open

    def connect(options = {})
      opts     = options.dup
      service  = (opts.delete(:service) || "Compute").to_s.camelize
      tenant   = opts.delete(:tenant_name)
      discover_tenants = opts.fetch(:discover_tenants, true)
Severity: Minor
Found in lib/manageiq/providers/openstack/legacy/openstack_handle/handle.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 find_meter_counters has a Cognitive Complexity of 13 (exceeds 11 allowed). Consider refactoring.
Open

  def find_meter_counters(metric_capture_module, resource_filter, metadata_filter, log_header)
    counters = self.class.counters_by_vm.dig(ems.id, target.ems_ref)
    if counters.nil?
      counters = list_resource_meters(resource_filter, log_header) + list_metadata_meters(metadata_filter, log_header)
      # With Gnocchi, the network metrics are not associated with the instance's resource id
Severity: Minor
Found in app/models/manageiq/providers/openstack/base_metrics_capture.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 raw_connect has a Cognitive Complexity of 13 (exceeds 11 allowed). Consider refactoring.
Open

    def self.raw_connect(username, password, auth_url, service = "Compute", extra_opts = nil)
      opts = {
        :openstack_auth_url      => auth_url,
        :openstack_username      => username,
        :openstack_api_key       => password,
Severity: Minor
Found in lib/manageiq/providers/openstack/legacy/openstack_handle/handle.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 make_interpolation! has a Cognitive Complexity of 12 (exceeds 11 allowed). Consider refactoring.
Open

  def make_interpolation!(attributes_hash)
    # As specified in python doc, there is special section named 'DEFAULT', that has default values for all sections
    default_section_hash = attributes_hash['DEFAULT'] || {}

    # Functionality of python's class configparser.BasicInterpolation

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

  def do_volume_creation_check(volumes_refs)
    connection_options = {:service => "volume", :tenant_name => cloud_tenant.try(:name)}
    source.ext_management_system.with_provider_connection(connection_options) do |service|
      volumes_refs.each do |volume_attrs|
        next unless volume_attrs[:source_type] == "volume"

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

  def miq_templates
    collector.images.each do |i|
      parent_server_uid = parse_image_parent_id(i)
      image = persister.miq_templates.find_or_build(i.id)
      image.type = "#{persister.cloud_manager.class}::Template"

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

  def each_batch
    while @collecting_events && @qdr_receiver.running > 0
      @events_mutex.synchronize do
        converted_events = @events.map do |raw_event|
          unserialized_event = unserialize_event(raw_event)

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