ManageIQ/manageiq-providers-vmware

View on GitHub

Showing 34 of 127 total issues

Method vim_connect has a Cognitive Complexity of 15 (exceeds 11 allowed). Consider refactoring.
Open

  def vim_connect(options = {})
    raise _("no console credentials defined") if options[:auth_type] == :console && !authentication_type(options[:auth_type])
    raise _("no credentials defined") if missing_credentials?(options[:auth_type])

    options[:ip]   ||= hostname
Severity: Minor
Found in app/models/manageiq/providers/vmware/infra_manager/vim_connect_mixin.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 vms_and_templates_reconnect_block has a Cognitive Complexity of 15 (exceeds 11 allowed). Consider refactoring.
Open

  def vms_and_templates_reconnect_block
    lambda do |inventory_collection, inventory_objects_index, attributes_index|
      relation = inventory_collection.model_class.where(:ems_id => nil)
      return if relation.count <= 0

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

  def customization_nicSettingMap(source_platform, spec)
    nic_settings = collect_nic_settings

    spec.nicSettingMap ||= VimArray.new("ArrayOfCustomizationAdapterMapping")

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

    def parse_host_system_lans(object, host, switches, props)
      network = props.fetch_path(:config, :network)
      return if network.blank?

      switch_uids = switches.index_by(&:name)

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

    def parse_virtual_machine_networks(_vm, props, hardware, guest_devices)
      summary_guest = props.fetch_path(:summary, :guest)
      return if summary_guest.nil?

      hostname = summary_guest[:hostName]

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

  def vapp_networks
    return @vapp_networks if @vapp_networks.any?

    @vapp_networks = vapps.each_with_object([]) do |vapp, res|
      fetch_network_configurations_for_vapp(vapp.id).map do |net_conf|
Severity: Minor
Found in app/models/manageiq/providers/vmware/inventory/collector.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 get_network_device has a Cognitive Complexity of 13 (exceeds 11 allowed). Consider refactoring.
Open

  def get_network_device(vimVm, _vmcs, _vim = nil, vlan = nil)
    svm = source
    nic = svm.hardware.nil? ? nil : svm.hardware.nics.first
    unless nic.nil?
      # if passed a vlan, validate that the target host supports it.

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

  def build_config_spec_advanced_lan(network, vnicDev, vmcs)
    # A DistributedVirtualPortgroup name is unique in a datacenter so look for a Lan with this name
    # on all switches in the cluster
    hosts = dest_cluster.try(:hosts) || dest_host
    lan = Lan.find_by(:name => network[:network], :switch_id => HostSwitch.where(:host_id => hosts).pluck(:switch_id))

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

  def get_array_entry(array, key)
    return nil, nil unless array.kind_of?(Array)

    array.each_index do |n|
      array_entry = array[n]

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

    def parse_host_system_host_networks(_host, hardware, props)
      network = props.fetch_path(:config, :network)
      return if network.nil?

      vnics = Array(network[:consoleVnic]) + Array(network[:vnic])

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

  private def convert_vlan_options_to_network_hash
    vlan = get_option(:vlan)
    _log.info("vlan: #{vlan.inspect}")
    return unless vlan

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

  def self.counter_info_by_counter_id(ems, vim_hist)
    phr = perf_history_results
    results = phr.fetch_path(:counter_info_by_id, ems.id)
    return results unless results.nil?

Severity: Minor
Found in app/models/manageiq/providers/vmware/infra_manager/metrics_capture.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 process_prop_change has a Cognitive Complexity of 12 (exceeds 11 allowed). Consider refactoring.
Open

  def process_prop_change(prop_hash, prop_change)
    h, prop_str = hash_target(prop_hash, prop_change.name)
    tag, key    = tag_and_key(prop_str)

    case prop_change.op

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

  def build_customization_spec
    sysprep_option = get_option(:sysprep_enabled)
    if sysprep_option.blank? || sysprep_option == 'disabled'
      _log.warn "VM Customization will be skipped.  Sysprep customization option set to [#{sysprep_option}]"
      return nil

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