ManageIQ/manageiq-automation_engine

View on GitHub

Showing 21 of 118 total issues

Method initialize has a Cognitive Complexity of 55 (exceeds 11 allowed). Consider refactoring.
Open

    def initialize(workspace, namespace, klass, instance, object_name = nil)
      Benchmark.current_realtime[:object_count] += 1

      @workspace        = workspace
      @namespace        = namespace
Severity: Minor
Found in lib/miq_automation_engine/engine/miq_ae_engine/miq_ae_object.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 instantiate has a Cognitive Complexity of 35 (exceeds 11 allowed). Consider refactoring.
Open

    def instantiate(uri, user, root = nil)
      @ae_user = user
      @dom_search.ae_user = user
      scheme, _userinfo, _host, _port, _registry, path, _opaque, query, fragment = MiqAeUri.split(uri, "miqaedb")

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

    def self.process_fields(fields)
      priority = 0
      ae_fields = []
      fields.each do |field|
        field["MiqAeField"].each do |f|
Severity: Minor
Found in app/models/miq_ae_datastore/xml_import.rb - About 3 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_result has a Cognitive Complexity of 27 (exceeds 11 allowed). Consider refactoring.
Open

  def self.process_result(ae_result, aevent)
    scheme, _userinfo, _host, _port, _registry, _path, _opaque, query, _fragment = MiqAeEngine::MiqAeUri.split(ae_result)
    args = MiqAeEngine::MiqAeUri.query2hash(query)

    if scheme.casecmp('miqpeca').zero?
Severity: Minor
Found in lib/miq_automation_engine/engine/miq_ae_event.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 process_state has a Cognitive Complexity of 26 (exceeds 11 allowed). Consider refactoring.
Open

    def process_state(field, message, args)
      Benchmark.current_realtime[:state_count] += 1
      Benchmark.realtime_block(:state_time) do
        # Initialize the ae_state and ae_result variables, if blank
        @workspace.root['ae_state']  = field['name'] if @workspace.root['ae_state'].blank?

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

  def self.deliver(*args)
    options     = options_from_args(args)
    user_obj    = ae_user_object(options)
    state       = options[:state]
    vmdb_object = nil
Severity: Minor
Found in lib/miq_automation_engine/engine/miq_ae_engine.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 process_collect_hash has a Cognitive Complexity of 23 (exceeds 11 allowed). Consider refactoring.
Open

    def process_collect_hash(expr, rels, result)
      lh       = result[1].strip unless result[1].nil?
      contents = result[2].strip

      hash = {}
Severity: Minor
Found in lib/miq_automation_engine/engine/miq_ae_engine/miq_ae_object.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 build_evm_event has a Cognitive Complexity of 23 (exceeds 11 allowed). Consider refactoring.
Open

  def self.build_evm_event(event, passed_inputs = {})
    inputs = passed_inputs.dup

    # TODO: Add to Request Logs
    $miq_ae_logger.info("MiqAeEvent.build_evm_event >> event=<#{event.inspect}> inputs=<#{inputs.inspect}>")
Severity: Minor
Found in lib/miq_automation_engine/engine/miq_ae_event.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 get_obj_from_path has a Cognitive Complexity of 21 (exceeds 11 allowed). Consider refactoring.
Open

    def get_obj_from_path(path)
      obj = current_object

      return obj if path.nil? || path.blank?

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

    def self.miq_host_and_storage_least_utilized(obj, _inputs)
      prov = obj.workspace.get_obj_from_path("/")['miq_provision']
      raise MiqAeException::MethodParmMissing, "Provision not specified" if prov.nil?

      vm = prov.vm_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 expose has a Cognitive Complexity of 19 (exceeds 11 allowed). Consider refactoring.
Open

    def self.expose(*args)
      raise ArgumentError, "must pass at least one method name" if args.empty? || args.first.kind_of?(Hash)

      options = args.last.kind_of?(Hash) ? args.pop : {}
      raise ArgumentError, "cannot have :method option if there is more than one method name specified" if options.key?(:method) && args.length != 1

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

    def self.load_xml(filename, domain_name = nil)
      _, t = Benchmark.realtime_block(:total_load_xml_time) do
        classes = buttons = nil
        Benchmark.realtime_block(:xml_load_time) do
          require 'xml/xml_hash'
Severity: Minor
Found in app/models/miq_ae_datastore/xml_import.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 find_named_ancestor has a Cognitive Complexity of 15 (exceeds 11 allowed). Consider refactoring.
Open

    def find_named_ancestor(path)
      path = path[1..-1] if path[0] == '/'
      plist = path.split("/")
      raise MiqAeException::InvalidPathFormat, "Unsupported Path [#{path}]" if plist[0].blank?

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

    def uri2value(uri, required = false)
      scheme, _userinfo, _host, _port, _registry, path, _opaque, _query, fragment = MiqAeUri.split(uri)

      if scheme == 'miqaedb'
        ns, klass, instance, attribute_name = MiqAePath.split(path, :has_attribute_name => true)
Severity: Minor
Found in lib/miq_automation_engine/engine/miq_ae_engine/miq_ae_object.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 convert_value_based_on_datatype has a Cognitive Complexity of 15 (exceeds 11 allowed). Consider refactoring.
Open

    def self.convert_value_based_on_datatype(value, datatype)
      return value if value.blank? || datatype.nil?

      # Basic Types
      return convert_boolean_value(value)                    if datatype == 'boolean'
Severity: Minor
Found in lib/miq_automation_engine/engine/miq_ae_engine/miq_ae_object.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 automate_attrs_from_options has a Cognitive Complexity of 14 (exceeds 11 allowed). Consider refactoring.
Open

  private_class_method def self.automate_attrs_from_options(options)
    automate_attrs = options[:attrs].dup
    automate_attrs['User::user']        = options[:user_id]           unless options[:user_id].nil?
    automate_attrs[:ae_state]           = options[:state]             unless options[:state].nil?
    automate_attrs[:ae_fsm_started]     = options[:ae_fsm_started]    unless options[:ae_fsm_started].nil?
Severity: Minor
Found in lib/miq_automation_engine/engine/miq_ae_engine.rb - About 45 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 import_domain has a Cognitive Complexity of 14 (exceeds 11 allowed). Consider refactoring.
Open

  def import_domain(domain_folder, domain_name)
    domain_yaml = domain_properties(domain_folder, domain_name)
    domain_name = domain_yaml.fetch_path('object', 'attributes', 'name')
    domain_source = domain_yaml.fetch_path('object', 'attributes', 'source')
    domain_obj = MiqAeDomain.lookup_by_fqname(domain_name, false)
Severity: Minor
Found in app/models/miq_ae_yaml_import.rb - About 45 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 preimport_check has a Cognitive Complexity of 13 (exceeds 11 allowed). Consider refactoring.
Open

  def preimport_check(domain_name, source_dom_source, dest_dom_source)
    dest_domain_name = @options['import_as'] == '*' || @options['import_as'].nil? ? @domain_name : @options['import_as']
    if source_dom_source == MiqAeDomain::SYSTEM_SOURCE
      if @options['git_repository_id']
        raise MiqAeException::InvalidDomain, _('Git based system domain import is not supported.')
Severity: Minor
Found in app/models/miq_ae_yaml_import.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 expose_class_attributes has a Cognitive Complexity of 13 (exceeds 11 allowed). Consider refactoring.
Open

    def self.expose_class_attributes(subclass)
      subclass.class_eval do
        model.attribute_names.each do |attr|
          next if model.private_method_defined?(attr)
          next if EXPOSED_ATTR_BLACK_LIST.any? { |rexp| attr =~ rexp }

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

  def self.raise_ems_event(event)
    aevent = {
      :event_id        => event.id,
      :event_stream_id => event.id,
      :event_type      => event.event_type,
Severity: Minor
Found in lib/miq_automation_engine/engine/miq_ae_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

Severity
Category
Status
Source
Language