HewlettPackard/oneview-sdk-ruby

View on GitHub

Showing 225 of 225 total issues

Similar blocks of code found in 2 locations. Consider refactoring.
Open

module OneviewSDK
  module API600
    module C7000
      # Enclosure resource implementation for API600 C7000
      class Enclosure < OneviewSDK::API500::C7000::Enclosure
Severity: Major
Found in lib/oneview-sdk/resource/api600/c7000/enclosure.rb and 1 other location - About 3 hrs to fix
lib/oneview-sdk/resource/api600/synergy/enclosure.rb on lines 14..66

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 121.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

module OneviewSDK
  module API600
    module Synergy
      # Enclosure resource implementation for API600 Synergy
      class Enclosure < OneviewSDK::API500::Synergy::Enclosure
Severity: Major
Found in lib/oneview-sdk/resource/api600/synergy/enclosure.rb and 1 other location - About 3 hrs to fix
lib/oneview-sdk/resource/api600/c7000/enclosure.rb on lines 14..66

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 121.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Method initialize has a Cognitive Complexity of 23 (exceeds 5 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 3 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

Method rest has a Cognitive Complexity of 22 (exceeds 5 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 3 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

Method client_setup has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

    def client_setup(client_params = {}, quiet = false, throw_errors = false)
      client_params['ssl_enabled'] = true if @options['ssl_verify'] == true
      client_params['ssl_enabled'] = false if @options['ssl_verify'] == false
      client_params['url'] ||= @options['url'] if @options['url']
      client_params['log_level'] ||= @options['log_level'].to_sym if @options['log_level']
Severity: Minor
Found in lib/oneview-sdk/cli.rb - About 2 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 ServerProfile has 24 methods (exceeds 20 allowed). Consider refactoring.
Open

    class ServerProfile < Resource
      include OneviewSDK::ResourceHelper::PatchOperation
      BASE_URI = '/rest/server-profiles'.freeze
      UNIQUE_IDENTIFIERS = %w[name uri associatedServer serialNumber serverHardwareUri].freeze

Severity: Minor
Found in lib/oneview-sdk/resource/api200/server_profile.rb - About 2 hrs to fix

    Method parse_type has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Open

        def parse_type(type)
          api_ver = (@options['api_version'] || ENV['ONEVIEWSDK_API_VERSION'] || OneviewSDK.api_version).to_i
          unless OneviewSDK::SUPPORTED_API_VERSIONS.include?(api_ver)
            # Find and use the best available match for the desired API version (round down to nearest)
            valid_api_ver = OneviewSDK::SUPPORTED_API_VERSIONS.select { |x| x <= api_ver }.max || OneviewSDK::SUPPORTED_API_VERSIONS.min
    Severity: Minor
    Found in lib/oneview-sdk/cli.rb - About 2 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

    Method cert has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Open

        def cert(type, url = ENV['ONEVIEWSDK_URL'])
          case type.downcase
          when 'check'
            fail_nice 'Must specify a url' unless url
            puts "Checking certificate for '#{url}' ..."
    Severity: Minor
    Found in lib/oneview-sdk/cli.rb - About 2 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

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

    module OneviewSDK
      module API600
        module C7000
          # Ethernet network resource implementation for API600 C7000
          class EthernetNetwork < OneviewSDK::API500::C7000::EthernetNetwork
    Severity: Major
    Found in lib/oneview-sdk/resource/api600/c7000/ethernet_network.rb and 1 other location - About 2 hrs to fix
    lib/oneview-sdk/resource/api600/synergy/ethernet_network.rb on lines 14..42

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 92.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

    module OneviewSDK
      module API600
        module Synergy
          # Ethernet network resource implementation for API600 Synergy
          class EthernetNetwork < OneviewSDK::API500::Synergy::EthernetNetwork
    Severity: Major
    Found in lib/oneview-sdk/resource/api600/synergy/ethernet_network.rb and 1 other location - About 2 hrs to fix
    lib/oneview-sdk/resource/api600/c7000/ethernet_network.rb on lines 14..42

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 92.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Method create_from_file has a Cognitive Complexity of 18 (exceeds 5 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 2 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 Cli has 22 methods (exceeds 20 allowed). Consider refactoring.
    Open

      class Cli < Thor
        # Runner class to enable testing
        class Runner
          def initialize(argv, stdin = STDIN, stdout = STDOUT, stderr = STDERR, kernel = Kernel)
            @argv = argv
    Severity: Minor
    Found in lib/oneview-sdk/cli.rb - About 2 hrs to fix

      Identical blocks of code found in 3 locations. Consider refactoring.
      Open

            def utilization(queryParameters = {})
              ensure_client && ensure_uri
              uri = "#{@data['uri']}/utilization?"
      
              queryParameters[:endDate]   = convert_time(queryParameters[:endDate])
      Severity: Major
      Found in lib/oneview-sdk/resource/api200/server_hardware.rb and 2 other locations - About 2 hrs to fix
      lib/oneview-sdk/resource/api200/enclosure.rb on lines 134..155
      lib/oneview-sdk/resource/api200/power_device.rb on lines 138..159

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 82.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Identical blocks of code found in 3 locations. Consider refactoring.
      Open

            def utilization(queryParameters = {})
              ensure_client && ensure_uri
              uri = "#{@data['uri']}/utilization?"
      
              queryParameters[:endDate]   = convert_time(queryParameters[:endDate])
      Severity: Major
      Found in lib/oneview-sdk/resource/api200/enclosure.rb and 2 other locations - About 2 hrs to fix
      lib/oneview-sdk/resource/api200/power_device.rb on lines 138..159
      lib/oneview-sdk/resource/api200/server_hardware.rb on lines 183..204

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 82.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Identical blocks of code found in 3 locations. Consider refactoring.
      Open

            def utilization(queryParameters = {})
              ensure_client && ensure_uri
              uri = "#{@data['uri']}/utilization?"
      
              queryParameters[:endDate]   = convert_time(queryParameters[:endDate])
      Severity: Major
      Found in lib/oneview-sdk/resource/api200/power_device.rb and 2 other locations - About 2 hrs to fix
      lib/oneview-sdk/resource/api200/enclosure.rb on lines 134..155
      lib/oneview-sdk/resource/api200/server_hardware.rb on lines 183..204

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 82.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Method retrieve! has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

              def retrieve!
                data_temp = JSON.parse(@data.to_json)
                serial_number = data_temp['deviceSpecificAttributes']['serialNumber'] rescue nil
                wwn = data_temp['deviceSpecificAttributes']['wwn'] rescue nil
      
      
      Severity: Minor
      Found in lib/oneview-sdk/resource/api500/c7000/storage_system.rb - About 2 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

      Method select_attributes has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

          def select_attributes(attributes, data = {})
            attributes = attributes.split(',').map(&:strip).reject(&:empty?).map { |a| a.split('.') } if attributes.is_a?(String)
            r_data = data.is_a?(Hash) ? data : data.data
            temp = {}
            attributes.each do |attr|
      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

      Similar blocks of code found in 4 locations. Consider refactoring.
      Open

      if @client.api_version.to_i > 200 && @client.api_version.to_i < 600
        scope_1 = scope_class.new(@client, name: 'Scope 1')
        scope_1.create!
        scope_2 = scope_class.new(@client, name: 'Scope 2')
        scope_2.create!
      Severity: Major
      Found in examples/shared_samples/ethernet_network.rb and 3 other locations - About 1 hr to fix
      examples/shared_samples/fc_network.rb on lines 75..100
      examples/shared_samples/fcoe_network.rb on lines 69..94
      examples/shared_samples/logical_interconnect_group.rb on lines 187..212

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 74.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 4 locations. Consider refactoring.
      Open

      if @client.api_version.to_i > 200 && @client.api_version.to_i < 600
        scope_1 = scope_class.new(@client, name: 'Scope 1')
        scope_1.create!
        scope_2 = scope_class.new(@client, name: 'Scope 2')
        scope_2.create!
      Severity: Major
      Found in examples/shared_samples/fc_network.rb and 3 other locations - About 1 hr to fix
      examples/shared_samples/ethernet_network.rb on lines 104..129
      examples/shared_samples/fcoe_network.rb on lines 69..94
      examples/shared_samples/logical_interconnect_group.rb on lines 187..212

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 74.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 4 locations. Consider refactoring.
      Open

      if @client.api_version.to_i > 200 && @client.api_version.to_i < 600
        scope_1 = scope_class.new(@client, name: 'Scope 1')
        scope_1.create!
        scope_2 = scope_class.new(@client, name: 'Scope 2')
        scope_2.create!
      Severity: Major
      Found in examples/shared_samples/logical_interconnect_group.rb and 3 other locations - About 1 hr to fix
      examples/shared_samples/ethernet_network.rb on lines 104..129
      examples/shared_samples/fc_network.rb on lines 75..100
      examples/shared_samples/fcoe_network.rb on lines 69..94

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 74.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Severity
      Category
      Status
      Source
      Language