HewlettPackard/oneview-sdk-ruby

View on GitHub

Showing 116 of 225 total issues

Method add_lig_to_bay has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

        def add_lig_to_bay(bay, lig, enclosureIndex)
          @data['interconnectBayMappings'].each do |location|
            next unless location['interconnectBay'] == bay
            if enclosureIndex
              next unless location['enclosureIndex'] == enclosureIndex
Severity: Minor
Found in lib/oneview-sdk/resource/api300/c7000/enclosure_group.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 retrieve! has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

      def retrieve!
        hostname = @data['hostname'] || @data['mpHostInfo']['mpHostName'] rescue nil
        if hostname
          results = self.class.find_by(@client, 'mpHostInfo' => { 'mpHostName' => hostname })
          if results.size == 1
Severity: Minor
Found in lib/oneview-sdk/resource/api200/server_hardware.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 from_file has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    def self.from_file(client, file_path)
      resource = OneviewSDK::Config.load(file_path)
      klass = self
      if klass == OneviewSDK::Resource && resource['type'] # Use correct resource class by parsing type
        klass = OneviewSDK # Secondary/temp class/module reference
Severity: Minor
Found in lib/oneview-sdk/resource.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 retrieve! has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

      def retrieve!
        ip_hostname = self['credentials'][:ip_hostname] || self['credentials']['ip_hostname'] rescue nil
        if ip_hostname
          results = self.class.find_by(@client, credentials: { ip_hostname: ip_hostname })
          if results.size == 1
Severity: Minor
Found in lib/oneview-sdk/resource/api200/storage_system.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 create_volume_with_attachment has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

      def create_volume_with_attachment(storage_pool, volume_options, attachment_options = {})
        raise IncompleteResource, 'Storage Pool not found!' unless storage_pool.retrieve!
        # Convert symbols keys to string in volume_options and attachment_options
        volume_options = Hash[volume_options.map { |k, v| [k.to_s, v] }]
        attachment_options = Hash[attachment_options.map { |k, v| [k.to_s, v] }]
Severity: Minor
Found in lib/oneview-sdk/resource/api200/server_profile.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 like? has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

      def like?(other)
        if other.is_a? Hash
          other_copy = Marshal.load(Marshal.dump(other))
        else
          other_copy = other.dup
Severity: Minor
Found in lib/oneview-sdk/resource/api200/storage_system.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 upload_file has 33 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def upload_file(file_path, path, options = {}, timeout = READ_TIMEOUT)
      raise NotFound, "ERROR: File '#{file_path}' not found!" unless File.file?(file_path)
      options = Hash[options.map { |k, v| [k.to_s, v] }]
      body_params = options['body'] || {}
      headers_params = options['header'] || {}
Severity: Minor
Found in lib/oneview-sdk/rest.rb - About 1 hr to fix

    Method create_from_file has 32 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def create_from_file(file_path)
          client_setup
          resource = OneviewSDK::Resource.from_file(@client, file_path)
          fail_nice 'Failed to determine resource type!' if resource.class == OneviewSDK::Resource
          existing_resource = resource.class.new(@client, resource.data)
    Severity: Minor
    Found in lib/oneview-sdk/cli.rb - About 1 hr to fix

      Method initialize has 32 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def initialize(options = {})
            options = Hash[options.map { |k, v| [k.to_sym, v] }] # Convert string hash keys to symbols
            STDOUT.sync = true
            @logger = options[:logger] || Logger.new(STDOUT)
            %i[debug info warn error level=].each { |m| raise InvalidClient, "Logger must respond to #{m} method " unless @logger.respond_to?(m) }
      Severity: Minor
      Found in lib/oneview-sdk/client.rb - About 1 hr to fix

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

            def response_handler(response, wait_on_task = true)
              case response.code.to_i
              when RESPONSE_CODE_OK # Synchronous read/query
                begin
                  return JSON.parse(response.body)
        Severity: Minor
        Found in lib/oneview-sdk/rest.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 retrieve! has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

              def retrieve!
                raise IncompleteResource, 'Must set resource name or uri before trying to retrieve!' unless @data['name'] || @data['uri']
                raise IncompleteResource, 'Must set resource storageSystemUri before trying to retrieve!' unless @data['storageSystemUri']
                results = self.class.find_by(@client, name: @data['name'], storageSystemUri: @data['storageSystemUri']) if @data['name']
                results = self.class.find_by(@client, uri:  @data['uri'], storageSystemUri: @data['storageSystemUri']) if @data['uri'] &&
        Severity: Minor
        Found in lib/oneview-sdk/resource/api200/storage_pool.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 response_handler has 29 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def response_handler(response, wait_on_task = true)
              case response.code.to_i
              when RESPONSE_CODE_OK # Synchronous read/query
                begin
                  return JSON.parse(response.body)
        Severity: Minor
        Found in lib/oneview-sdk/rest.rb - About 1 hr to fix

          Method generate_logical_switch_credential_configuration has 29 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                def generate_logical_switch_credential_configuration
                  configuration = []
                  @logical_switch_credentials.each do |host, switch|
                    switch_configuration = {
                      'snmpPort' => switch[1].port,
          Severity: Minor
          Found in lib/oneview-sdk/resource/api200/logical_switch.rb - About 1 hr to fix

            Method build_request has 29 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                def build_request(type, uri, options, api_ver)
                  case type.downcase.to_sym
                  when :get
                    request = Net::HTTP::Get.new(uri.request_uri)
                  when :post
            Severity: Minor
            Found in lib/oneview-sdk/rest.rb - About 1 hr to fix

              Method rest has 28 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  def rest(method, uri)
                    log_level = @options['log_level'] == :warn ? :error : @options['log_level'].to_sym # Default to :error
                    client_setup('log_level' => log_level)
                    uri_copy = uri.dup
                    uri_copy.prepend('/') unless uri_copy.start_with?('/')
              Severity: Minor
              Found in lib/oneview-sdk/cli.rb - About 1 hr to fix

                Method initialize has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                      def initialize(options = {})
                        options = Hash[options.map { |k, v| [k.to_sym, v] }] # Convert string hash keys to symbols
                        STDOUT.sync = true
                        @logger = options[:logger] || Logger.new(STDOUT)
                        %i[debug info warn error level=].each { |m| raise InvalidClient, "Logger must respond to #{m} method " unless @logger.respond_to?(m) }
                Severity: Minor
                Found in lib/oneview-sdk/image-streamer/client.rb - About 1 hr to fix

                  Method output has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      def output(data = {}, indent = 0)
                        case @options['format']
                        when 'json'
                          puts JSON.pretty_generate(data)
                        when 'yaml'
                  Severity: Minor
                  Found in lib/oneview-sdk/cli.rb - About 1 hr to fix

                    Method exists? has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                    Open

                          def exists?
                            hostname = @data['hostname'] || @data['mpHostInfo']['mpHostName'] rescue nil
                            return true if hostname && self.class.find_by(@client, 'mpHostInfo' => { 'mpHostName' => hostname }).size == 1
                            super
                          rescue IncompleteResource => e
                    Severity: Minor
                    Found in lib/oneview-sdk/resource/api200/server_hardware.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 add_logical_interconnect_group has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                    Open

                            def add_logical_interconnect_group(lig, enclosureIndex = nil)
                              lig.retrieve! unless lig['uri']
                              raise(NotFound, "The logical interconnect group #{lig['name']} was not found") unless lig['uri']
                              lig['interconnectMapTemplate']['interconnectMapEntryTemplates'].each do |entry|
                                entry['logicalLocation']['locationEntries'].each do |location|
                    Severity: Minor
                    Found in lib/oneview-sdk/resource/api300/c7000/enclosure_group.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 create_volume_with_attachment has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                    Open

                            def create_volume_with_attachment(storage_pool, volume_options, attachment_options = {})
                              raise IncompleteResource, 'Storage Pool not found!' unless storage_pool.retrieve!
                              # Convert symbols keys to string in volume_options and attachment_options
                              volume_options = Hash[volume_options.map { |k, v| [k.to_s, v] }]
                              attachment_options = Hash[attachment_options.map { |k, v| [k.to_s, v] }]
                    Severity: Minor
                    Found in lib/oneview-sdk/resource/api500/c7000/server_profile.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

                    Severity
                    Category
                    Status
                    Source
                    Language