HewlettPackard/oneview-sdk-ruby

View on GitHub

Showing 116 of 225 total issues

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

      def add_volume_attachment(volume, attachment_options = {})
        raise IncompleteResource, 'Volume not found!' unless volume.retrieve!
        # Convert symbols keys to string
        attachment_options = Hash[attachment_options.map { |k, v| [k.to_s, v] }]
        self['sanStorage'] ||= {}
Severity: Minor
Found in lib/oneview-sdk/resource/api200/server_profile_template.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 resource_named has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

      def self.resource_named(type, _variant = nil)
        new_type = type.to_s.downcase.gsub(/[ -_]/, '')
        constants.each do |c|
          klass = const_get(c)
          next unless klass.is_a?(Class) && klass < OneviewSDK::Resource
Severity: Minor
Found in lib/oneview-sdk/image-streamer/resource/api2000.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 env has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def env
      data = {}
      OneviewSDK::ENV_VARS.each { |k| data[k] = ENV[k] }
      if @options['format'] == 'human'
        data.each do |key, value|
Severity: Minor
Found in lib/oneview-sdk/cli.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 add_connection has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

        def add_connection(network, connection_options = {})
          connection_options = Hash[connection_options.map { |k, v| [k.to_s, v] }]
          self['connectionSettings'] = {} unless self['connectionSettings']
          self['connectionSettings']['connections'] = [] unless self['connectionSettings']['connections']
          connection_options['id'] ||= 0
Severity: Minor
Found in lib/oneview-sdk/resource/api600/c7000/server_profile.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 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 deep_merge! has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def deep_merge!(other_data, target_data = @data)
      raise 'Both arguments should be a object Hash' unless other_data.is_a?(Hash) && target_data.is_a?(Hash)
      other_data.each do |key, value|
        value_target = target_data[key.to_s]
        if value_target.is_a?(Hash) && value.is_a?(Hash)
Severity: Minor
Found in lib/oneview-sdk/resource.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 resource_named has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

      def self.resource_named(type, _variant = nil)
        new_type = type.to_s.downcase.gsub(/[ -_]/, '')
        constants.each do |c|
          klass = const_get(c)
          next unless klass.is_a?(Class) && klass < OneviewSDK::Resource
Severity: Minor
Found in lib/oneview-sdk/image-streamer/resource/api1600.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 create_volume_with_attachment has a Cognitive Complexity of 7 (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_template.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 resource_named has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

      def self.resource_named(type, _variant = nil)
        new_type = type.to_s.downcase.gsub(/[ -_]/, '')
        constants.each do |c|
          klass = const_get(c)
          next unless klass.is_a?(Class) && klass < OneviewSDK::Resource
Severity: Minor
Found in lib/oneview-sdk/image-streamer/resource/api600.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 resource_named has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

      def self.resource_named(type, _variant = nil)
        new_type = type.to_s.downcase.gsub(/[ -_]/, '')
        constants.each do |c|
          klass = const_get(c)
          next unless klass.is_a?(Class) && klass < OneviewSDK::Resource
Severity: Minor
Found in lib/oneview-sdk/image-streamer/resource/api2020.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 generate_logical_switch_credential_configuration has a Cognitive Complexity of 7 (exceeds 5 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 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 add_interconnect has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

      def add_interconnect(bay, type)
        interconnect_type = OneviewSDK::Interconnect.get_type(@client, type)
        unless interconnect_type
          list = OneviewSDK::Interconnect.get_types(@client).map { |t| t['name'] }
          raise OneviewSDK::NotFound, "Interconnect type #{type} not found! Supported types: #{list}"
Severity: Minor
Found in lib/oneview-sdk/resource/api200/logical_interconnect_group.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 resource_named has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

      def self.resource_named(type, _variant = nil)
        new_type = type.to_s.downcase.gsub(/[ -_]/, '')
        constants.each do |c|
          klass = const_get(c)
          next unless klass.is_a?(Class) && klass < OneviewSDK::Resource
Severity: Minor
Found in lib/oneview-sdk/image-streamer/resource/api800.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 login has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def login(retries = 2)
      options = {
        'body' => {
          'userName' => @user,
          'password' => @password,
Severity: Minor
Found in lib/oneview-sdk/client.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 initialize has a Cognitive Complexity of 7 (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 resource_named has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

      def self.resource_named(type, _variant = nil)
        new_type = type.to_s.downcase.gsub(/[ -_]/, '')
        constants.each do |c|
          klass = const_get(c)
          next unless klass.is_a?(Class) && klass < OneviewSDK::Resource
Severity: Minor
Found in lib/oneview-sdk/image-streamer/resource/api300.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

Avoid too many return statements within this method.
Open

          return false
Severity: Major
Found in lib/oneview-sdk/resource.rb - About 30 mins to fix

    Method resource_named has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def self.resource_named(type, _variant = nil)
          new_type = type.to_s.downcase.gsub(/[ -_]/, '')
          constants.each do |c|
            klass = const_get(c)
            next unless klass.is_a?(Class)
    Severity: Minor
    Found in lib/oneview-sdk/resource/api200.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

    Method appliance_i3s_api_version has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

          def appliance_i3s_api_version
            options = { 'Content-Type' => :none, 'X-API-Version' => :none, 'auth' => :none }
            response = rest_api(:get, '/rest/version', options)
            version = response_handler(response)['currentVersion']
            raise ConnectionError, "Couldn't get API version" unless version
    Severity: Minor
    Found in lib/oneview-sdk/image-streamer/client.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

    Method update_enclosure_names has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

            def self.update_enclosure_names(client, hostname, name = '')
              raise IncompleteResource, 'Missing parameters for update_enclosure_names' unless client && hostname
              frame_link = ''
    
              # Retrieve the frameLinkModuleDomain of the specified enclosure, then use it to find all enclosures
    Severity: Minor
    Found in lib/oneview-sdk/resource/api300/synergy/enclosure.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