HewlettPackard/oneview-chef

View on GitHub

Showing 43 of 65 total issues

Method recursive_diff has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
Open

    def self.recursive_diff(data, desired_data, str = '', indent = '')
      unless desired_data.class == Hash
        return '' if data == desired_data
        return str << "\n#{indent}#{data.nil? ? 'nil' : data} -> #{desired_data}"
      end
Severity: Minor
Found in libraries/oneview_helper.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

Class ResourceProvider has 21 methods (exceeds 20 allowed). Consider refactoring.
Open

  class ResourceProvider
    attr_accessor \
      :context,       # Ususally a Chef resource's context (self)
      :resource_name, # The Chef resource's type. e.g., oneview_ethernet_network
      :name,          # Name of the Chef resource. e.g., EthNet1
Severity: Minor
Found in libraries/resource_provider.rb - About 2 hrs to fix

    Method modify_resource_scopes_assignments has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

            def modify_resource_scopes_assignments
              return Chef::Log.info('No resource were specified to modify resource scopes. Skipping') if @new_resource.resource.nil?
              add_or_remove = @new_resource.add.any? || @new_resource.remove.any?
              raise "Unspecified properties: 'add' and 'remove'. Please set at least one before attempting this action." unless add_or_remove
              client = OneviewCookbook::Helper.build_client(@new_resource.client)
    Severity: Minor
    Found in libraries/resource_providers/api600/c7000/scope_provider.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 build_volume_attachments has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

          def build_volume_attachments
            @new_resource.volume_attachments.each do |options|
              options = convert_keys(options, :to_s)
              volume_name = options['volume']
              volume_data = options['volume_data']
    Severity: Minor
    Found in libraries/resource_providers/api200/server_profile_provider.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 load_resource has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

        def self.load_resource(client, type: nil, id: nil, ret_attribute: nil, api_ver: nil, variant: nil, node: nil, base_module: OneviewSDK)
          raise(ArgumentError, 'Must specify a resource type') unless type
          return unless id
          c = build_client(client)
          api_ver ||= node['oneview']['api_version'] rescue 200
    Severity: Minor
    Found in libraries/oneview_helper.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 parse_namespace has 35 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def parse_namespace
          klass_name = self.class.to_s
          Chef::Log.debug("Resource '#{@resource_name}' received with the '#{klass_name}' class name")
          name_arr = klass_name.split('::')
          @sdk_resource_type = name_arr.pop.gsub(/Provider$/i, '') # e.g., EthernetNetwork
    Severity: Minor
    Found in libraries/resource_provider.rb - About 1 hr to fix

      Method convert_keys has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

          def self.convert_keys(info, conversion_method)
            return nil unless info
            support = {}
            info.each do |k, v|
              if v.class == Hash
      Severity: Minor
      Found in libraries/oneview_helper.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 load_ports has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

            def load_ports(item_to_update)
              port_monitor_attributes = convert_keys(@new_resource.port_monitor, :to_s)
              enable_port_monitor = item_to_update['portMonitor']['enablePortMonitor'] if item_to_update['portMonitor']
              enable_port_monitor ||= port_monitor_attributes['enablePortMonitor']
              if enable_port_monitor

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

          def self.get_provider_named(type, api_module, variant = nil)
            api_version = api_module.to_s.split('::').last
            if variant
              raise "#{api_version} variant #{variant} is not supported!" unless api_module::SUPPORTED_VARIANTS.include?(variant.to_s)
              api_module = api_module.const_get(variant.to_s)
      Severity: Minor
      Found in libraries/oneview_helper.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 load_ligs has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

              def load_ligs
                load_lig # Deprecated method
                return unless @new_resource.logical_interconnect_groups
                lig_klass = resource_named(:LogicalInterconnectGroup)
                sas_lig_klass = resource_named(:SASLogicalInterconnectGroup)

      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_logical_switch has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

            def load_logical_switch
              lsg_defined = @new_resource.logical_switch_group || @item['LogicalSwitchGroupUri']
              raise "Undefined Property: 'logical_switch_group'. Please set it before attempting this action" unless lsg_defined
              unless @item['LogicalSwitchGroupUri']
                @item.set_logical_switch_group(load_resource(:LogicalSwitchGroup, @new_resource.logical_switch_group))
      Severity: Minor
      Found in libraries/resource_providers/api200/logical_switch_provider.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 change_resource_assignments has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

              def change_resource_assignments
                add_or_remove = @new_resource.add.any? || @new_resource.remove.any?
                raise "Unspecified properties: 'add' and 'remove'. Please set at least one before attempting this action." unless add_or_remove
                @item.retrieve! || raise("#{@resource_name} '#{@name}' not found!")
                values_to_add = build_resource_list
      Severity: Minor
      Found in libraries/resource_providers/api300/c7000/scope_provider.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 backup_from_file has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

              def backup_from_file
                raise "#{@resource_name} #{@new_resource.file_path} must be specified for this action" unless @new_resource.file_path
                raise "'#{@new_resource.file_path}' file does not exist." unless File.file?(@new_resource.file_path)
                raise 'A deployment_group field is required for this action.' unless @new_resource.deployment_group
                deployment_group = load_resource(:DeploymentGroup, @new_resource.deployment_group)

      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_resource_list has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

              def build_resource_list(op = :add)
                retrieved_resources = []
                context = op == :add ? @new_resource.add : @new_resource.remove
                context.each do |resource_name, values|
                  values.each do |value|
      Severity: Minor
      Found in libraries/resource_providers/api300/c7000/scope_provider.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 load_downlink_ports has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

            def load_downlink_ports(monitored_ports, interconnect_name)
              interconnect = load_resource(:Interconnect, interconnect_name)
              monitored_ports.each do |downlink|
                interconnect['ports'].each do |k|
                  next unless k['portName'] == downlink['portName']
      Severity: Minor
      Found in libraries/resource_providers/api200/logical_interconnect_provider.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 discover has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

            def discover
              pd_klass = resource_named(:PowerDevice)
              power_devices_list = pd_klass.get_ipdu_devices(@item.client, @name)
              return Chef::Log.info("#{@resource_name} '#{@name}' is up to date") unless power_devices_list.empty?
              Chef::Log.info "Discovering #{@resource_name} '#{@name}'"
      Severity: Minor
      Found in libraries/resource_providers/api200/power_device_provider.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 add_to_rack has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

            def add_to_rack
              raise "Unspecified property: 'mount_options'. Please set it before attempting this action." unless @new_resource.mount_options
              @item.retrieve! || raise("#{@resource_name} '#{@name}' not found!")
              mount_item = load_mount_item
              rack_uris = @item['rackMounts'].collect { |i| i['mountUri'] }
      Severity: Minor
      Found in libraries/resource_providers/api200/rack_provider.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 get_resource_class has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def self.get_resource_class(context, resource_type, base_module = OneviewCookbook)
            load_sdk(context)
            # Loads the api version if the property was specified directly
            context_api_version = context.new_resource.api_version if context.property_is_set?(:api_version)
            # Loads the api version if it was specified in the client
      Severity: Minor
      Found in libraries/oneview_helper.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 build_image_streamer_client has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def self.build_image_streamer_client(client = nil)
            Chef::Log.debug("Building Image Streamer client with:\n#{client}\n\n")
            case client
            when OneviewSDK::ImageStreamer::Client
              client
      Severity: Minor
      Found in libraries/oneview_helper.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 load_build_step has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

              def load_build_step
                return unless @item['buildStep']
                @item['buildStep'].collect! do |build_step|
                  step = convert_keys(build_step, :to_s)
                  next step if step['planScriptUri']

      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