HewlettPackard/oneview-sdk-ruby

View on GitHub

Showing 116 of 225 total issues

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

    def delete_from_file(file_path)
      client_setup
      resource = OneviewSDK::Resource.from_file(@client, file_path)
      fail_nice("#{resource.class.name.split('::').last} '#{resource[:name] || resource[:uri]}' Not Found", 2) unless resource.retrieve!
      return unless options['force'] || agree("Delete '#{resource[:name]}'? [Y/N] ")
Severity: Minor
Found in lib/oneview-sdk/cli.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 initialize has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

        def initialize(client, params = {}, api_ver = nil)
          super
          # Default values:
          @data['enclosureType'] ||= 'SY12000'
          @data['enclosureIndexes'] ||= [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 exists? has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

      def exists?
        ip_hostname = self['credentials'][:ip_hostname] || self['credentials']['ip_hostname'] rescue nil
        return true if ip_hostname && self.class.find_by(@client, credentials: { ip_hostname: ip_hostname }).size == 1
        super
      rescue IncompleteResource => e
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 update has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def update(type, name)
      resource_class = parse_type(type)
      client_setup
      fail_nice 'Must set the hash or json option' unless @options['hash'] || @options['json']
      fail_nice 'Must set the hash OR json option. Not both' if @options['hash'] && @options['json']
Severity: Minor
Found in lib/oneview-sdk/cli.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 find_with_pagination has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def self.find_with_pagination(client, uri, header = self::DEFAULT_REQUEST_HEADER)
      all = []
      loop do
        response = client.rest_get(uri, header)
        body = client.response_handler(response)
Severity: Minor
Found in lib/oneview-sdk/resource.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 create_volume_with_attachment has a Cognitive Complexity of 9 (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_template.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 build_query has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def self.build_query(query_options)
      return '' if !query_options || query_options.empty?
      query_path = '?'
      query_options.each do |k, v|
        words = k.to_s.split('_')
Severity: Minor
Found in lib/oneview-sdk/resource.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 set_enclosures has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

        def set_enclosures(enclosures = [])
          enclosureUris = []
          enclosures.each do |enclosure|
            enclosureUris.push(enclosure['uri']) if enclosure['uri'] || enclosure.retrieve!
            raise "Resource #{enclosure['name']} could not be found!" unless enclosure['uri']
Severity: Minor
Found in lib/oneview-sdk/resource/api300/synergy/logical_enclosure.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 resource_named has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def self.resource_named(type, variant = @variant)
      raise "API1800 variant '#{variant}' is not supported! Try one of #{SUPPORTED_VARIANTS}" unless SUPPORTED_VARIANTS.include?(variant.to_s)
      new_type = type.to_s.downcase.gsub(/[ -_]/, '')
      api_module = OneviewSDK::API1800.const_get(variant)
      api_module.constants.each do |c|
Severity: Minor
Found in lib/oneview-sdk/resource/api1800.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 resource_named has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def self.resource_named(type, variant = @variant)
      raise "API2400 variant '#{variant}' is not supported! Try one of #{SUPPORTED_VARIANTS}" unless SUPPORTED_VARIANTS.include?(variant.to_s)
      new_type = type.to_s.downcase.gsub(/[ -_]/, '')
      api_module = OneviewSDK::API2400.const_get(variant)
      api_module.constants.each do |c|
Severity: Minor
Found in lib/oneview-sdk/resource/api2400.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 install_cert has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def self.install_cert(url)
      uri = URI.parse(Addressable::URI.escape(url))
      raise InvalidURL, "Invalid url '#{url}'" unless uri.host
      options = { use_ssl: true, verify_mode: OpenSSL::SSL::VERIFY_NONE }
      pem = Net::HTTP.start(uri.host, uri.port, options) do |http|
Severity: Minor
Found in lib/oneview-sdk/ssl_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 resource_named has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def self.resource_named(type, variant = @variant)
      raise "API500 variant '#{variant}' is not supported! Try one of #{SUPPORTED_VARIANTS}" unless SUPPORTED_VARIANTS.include?(variant.to_s)
      new_type = type.to_s.downcase.gsub(/[ -_]/, '')
      api_module = OneviewSDK::API500.const_get(variant)
      api_module.constants.each do |c|
Severity: Minor
Found in lib/oneview-sdk/resource/api500.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 check_cert has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def self.check_cert(url)
      uri = URI.parse(Addressable::URI.escape(url))
      raise InvalidURL, "Invalid url '#{url}'" unless uri.host
      http = Net::HTTP.new(uri.host, uri.port)
      http.use_ssl = true if uri.scheme == 'https'
Severity: Minor
Found in lib/oneview-sdk/ssl_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 resource_named has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def self.resource_named(type, variant = @variant)
      raise "API3000 variant '#{variant}' is not supported! Try one of #{SUPPORTED_VARIANTS}" unless SUPPORTED_VARIANTS.include?(variant.to_s)
      new_type = type.to_s.downcase.gsub(/[ -_]/, '')
      api_module = OneviewSDK::API3000.const_get(variant)
      api_module.constants.each do |c|
Severity: Minor
Found in lib/oneview-sdk/resource/api3000.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 resource_named has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def self.resource_named(type, variant = @variant)
      raise "API1200 variant '#{variant}' is not supported! Try one of #{SUPPORTED_VARIANTS}" unless SUPPORTED_VARIANTS.include?(variant.to_s)
      new_type = type.to_s.downcase.gsub(/[ -_]/, '')
      api_module = OneviewSDK::API1200.const_get(variant)
      api_module.constants.each do |c|
Severity: Minor
Found in lib/oneview-sdk/resource/api1200.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 add_logical_interconnect_group has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

      def add_logical_interconnect_group(lig)
        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/api200/enclosure_group.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 resource_named has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def self.resource_named(type, variant = @variant)
      raise "API2000 variant '#{variant}' is not supported! Try one of #{SUPPORTED_VARIANTS}" unless SUPPORTED_VARIANTS.include?(variant.to_s)
      new_type = type.to_s.downcase.gsub(/[ -_]/, '')
      api_module = OneviewSDK::API2000.const_get(variant)
      api_module.constants.each do |c|
Severity: Minor
Found in lib/oneview-sdk/resource/api2000.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 resource_named has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def self.resource_named(type, variant = @variant)
      raise "API2600 variant '#{variant}' is not supported! Try one of #{SUPPORTED_VARIANTS}" unless SUPPORTED_VARIANTS.include?(variant.to_s)
      new_type = type.to_s.downcase.gsub(/[ -_]/, '')
      api_module = OneviewSDK::API2600.const_get(variant)
      api_module.constants.each do |c|
Severity: Minor
Found in lib/oneview-sdk/resource/api2600.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 resource_named has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def self.resource_named(type, variant = @variant)
      raise "API2800 variant '#{variant}' is not supported! Try one of #{SUPPORTED_VARIANTS}" unless SUPPORTED_VARIANTS.include?(variant.to_s)
      new_type = type.to_s.downcase.gsub(/[ -_]/, '')
      api_module = OneviewSDK::API2800.const_get(variant)
      api_module.constants.each do |c|
Severity: Minor
Found in lib/oneview-sdk/resource/api2800.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

Severity
Category
Status
Source
Language