HewlettPackard/oneview-sdk-ruby

View on GitHub
lib/oneview-sdk/rest.rb

Summary

Maintainability
C
1 day
Test Coverage

Method build_request has a Cognitive Complexity of 13 (exceeds 5 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

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

            def rest_api(type, path, options = {}, api_ver = @api_version, redirect_limit = 3)
              @logger.debug "Making :#{type} rest call to #{@url}#{path}"
              raise InvalidRequest, 'Must specify path' unless path
              uri = URI.parse(Addressable::URI.escape(@url + path))
              http = build_http_object(uri)
        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 rest_api has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def rest_api(type, path, options = {}, api_ver = @api_version, redirect_limit = 3)
        Severity: Minor
        Found in lib/oneview-sdk/rest.rb - About 35 mins to fix

          Method build_http_object has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              def build_http_object(uri)
                http = Net::HTTP.new(uri.host, uri.port)
                http.use_ssl = true if uri.scheme == 'https'
                if @ssl_enabled
                  http.cert_store = @cert_store if @cert_store
          Severity: Minor
          Found in lib/oneview-sdk/rest.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 upload_file has a Cognitive Complexity of 6 (exceeds 5 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 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

          There are no issues that match your filters.

          Category
          Status