fog/fog-xenserver

View on GitHub

Showing 81 of 81 total issues

Class has too many lines. [332/250]
Open

    class Compute < Fog::Service
      autoload :Models, File.expand_path("../compute/models", __FILE__)
      autoload :Real, File.expand_path("../compute/real", __FILE__)
      autoload :Mock, File.expand_path("../compute/mock", __FILE__)

Severity: Minor
Found in lib/fog/xenserver/compute.rb by rubocop

This cop checks if the length a class exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

File compute.rb has 339 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require "fog/core"

module Fog
  module XenServer
    class Compute < Fog::Service
Severity: Minor
Found in lib/fog/xenserver/compute.rb - About 4 hrs to fix

    Method db_introduce_pif has 21 arguments (exceeds 4 allowed). Consider refactoring.
    Open

            def db_introduce_pif(device, network, host, mac, mtu, vlan, physical, ip_configuration_mode, ip, netmask, gateway, dns, bond_slave_of, vlan_master_of, management, other_config, disallow_unplug, ipv6_configuration_mode, ipv6, ipv6_gateway, primary_address_type)
    Severity: Major
    Found in lib/fog/xenserver/compute/requests/db_introduce_pif.rb - About 2 hrs to fix

      Method db_introduce_vdi has 18 arguments (exceeds 4 allowed). Consider refactoring.
      Open

              def db_introduce_vdi(uuid, name_label, name_description, sr, type, sharable, read_only, other_config, location, xenstore_data, sm_config, managed, virtual_size, physical_utilisation, metadata_of_pool, is_a_snapshot, snapshot_time, snapshot_of)
      Severity: Major
      Found in lib/fog/xenserver/compute/requests/db_introduce_vdi.rb - About 2 hrs to fix

        Method introduce_vdi has 18 arguments (exceeds 4 allowed). Consider refactoring.
        Open

                def introduce_vdi(uuid, name_label, name_description, sr, type, sharable, read_only, other_config, location, xenstore_data, sm_config, managed, virtual_size, physical_utilisation, metadata_of_pool, is_a_snapshot, snapshot_time, snapshot_of)
        Severity: Major
        Found in lib/fog/xenserver/compute/requests/introduce_vdi.rb - About 2 hrs to fix

          Cyclomatic complexity for request is too high. [11/6]
          Open

                def request(options, *params)
                  begin
                    parser   = options.delete(:parser)
                    method   = options.delete(:method)
          
          
          Severity: Minor
          Found in lib/fog/xenserver/connection.rb by rubocop

          This cop checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.

          An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one.

          Cyclomatic complexity for parse is too high. [7/6]
          Open

                  def parse( data )
                    if data.kind_of? Hash
                      data.keys.each do |key|
                        data[key.to_sym] = data.delete(key) if key.respond_to?(:to_sym)
                      end
          Severity: Minor
          Found in lib/fog/xenserver/parsers/base.rb by rubocop

          This cop checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.

          An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one.

          Cyclomatic complexity for authenticate is too high. [7/6]
          Open

                def authenticate( username, password )
                  response = @factory.call("session.login_with_password", username.to_s, password.to_s)
                  unless response["Status"] =~ /Success/
                    if response.key?("ErrorDescription") &&
                       response["ErrorDescription"].is_a?(Array) &&
          Severity: Minor
          Found in lib/fog/xenserver/connection.rb by rubocop

          This cop checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.

          An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one.

          Avoid parameter lists longer than 5 parameters. [21/5]
          Open

                  def db_introduce_pif(device, network, host, mac, mtu, vlan, physical, ip_configuration_mode, ip, netmask, gateway, dns, bond_slave_of, vlan_master_of, management, other_config, disallow_unplug, ipv6_configuration_mode, ipv6, ipv6_gateway, primary_address_type)

          This cop checks for methods with too many parameters. The maximum number of parameters is configurable. Keyword arguments can optionally be excluded from the total count.

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

                def request(options, *params)
                  begin
                    parser   = options.delete(:parser)
                    method   = options.delete(:method)
          
          
          Severity: Minor
          Found in lib/fog/xenserver/connection.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

          Avoid parameter lists longer than 5 parameters. [18/5]
          Open

                  def db_introduce_vdi(uuid, name_label, name_description, sr, type, sharable, read_only, other_config, location, xenstore_data, sm_config, managed, virtual_size, physical_utilisation, metadata_of_pool, is_a_snapshot, snapshot_time, snapshot_of)

          This cop checks for methods with too many parameters. The maximum number of parameters is configurable. Keyword arguments can optionally be excluded from the total count.

          Avoid parameter lists longer than 5 parameters. [18/5]
          Open

                  def introduce_vdi(uuid, name_label, name_description, sr, type, sharable, read_only, other_config, location, xenstore_data, sm_config, managed, virtual_size, physical_utilisation, metadata_of_pool, is_a_snapshot, snapshot_time, snapshot_of)

          This cop checks for methods with too many parameters. The maximum number of parameters is configurable. Keyword arguments can optionally be excluded from the total count.

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

                  def parse( data )
                    if data.kind_of? Hash
                      data.keys.each do |key|
                        data[key.to_sym] = data.delete(key) if key.respond_to?(:to_sym)
                      end
          Severity: Minor
          Found in lib/fog/xenserver/parsers/base.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 authenticate has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

                def authenticate( username, password )
                  response = @factory.call("session.login_with_password", username.to_s, password.to_s)
                  unless response["Status"] =~ /Success/
                    if response.key?("ErrorDescription") &&
                       response["ErrorDescription"].is_a?(Array) &&
          Severity: Minor
          Found in lib/fog/xenserver/connection.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 assert_can_migrate_server has 6 arguments (exceeds 4 allowed). Consider refactoring.
          Open

                  def assert_can_migrate_server(ref, dest, live, vdi_map, vif_map, options)
          Severity: Minor
          Found in lib/fog/xenserver/compute/requests/assert_can_migrate_server.rb - About 45 mins to fix

            Method migrate_send_server has 6 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                    def migrate_send_server(ref, dest, live, vdi_map, vif_map, options)
            Severity: Minor
            Found in lib/fog/xenserver/compute/requests/migrate_send_server.rb - About 45 mins to fix

              Method introduce_sr has 6 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                      def introduce_sr(uuid, name_label, name_description, typecontent, sahred, sm_config)
              Severity: Minor
              Found in lib/fog/xenserver/compute/requests/introduce_sr.rb - About 45 mins to fix

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

                  module XenServer
                    class Compute
                      class Real
                        def templates
                          data = @connection.request(:parser => Fog::XenServer::Parsers::GetRecords.new, :method => "VM.get_all_records")
                Severity: Minor
                Found in lib/fog/xenserver/compute/requests/templates.rb and 1 other location - About 40 mins to fix
                lib/fog/xenserver/compute/requests/snapshots.rb on lines 2..11

                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 37.

                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 XenServer
                    class Compute
                      class Real
                        def snapshots
                          data = @connection.request(:parser => Fog::XenServer::Parsers::GetRecords.new, :method => "VM.get_all_records")
                Severity: Minor
                Found in lib/fog/xenserver/compute/requests/snapshots.rb and 1 other location - About 40 mins to fix
                lib/fog/xenserver/compute/requests/templates.rb on lines 2..11

                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 37.

                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 reconfigure_ipv6_pif has 5 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                        def reconfigure_ipv6_pif(ref, ipv6_configuration_mode, ipv6, gateway, dns)
                Severity: Minor
                Found in lib/fog/xenserver/compute/requests/reconfigure_ipv6_pif.rb - About 35 mins to fix
                  Severity
                  Category
                  Status
                  Source
                  Language