fog/fog-vsphere

View on GitHub

Showing 93 of 128 total issues

Avoid deeply nested control flow statements.
Open

                raise ArgumentError, 'identification->domainAdminPassword is required when using Sysprep identity and identification -> joinDomain' unless identity['Sysprep']['identification'].key?('domainAdmin')
Severity: Major
Found in lib/fog/vsphere/requests/compute/vm_clone.rb - About 45 mins to fix

    Method vm_execute has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

            def vm_execute(options = {})
              raise ArgumentError, 'instance_uuid is a required parameter' unless options.key? 'instance_uuid'
              raise ArgumentError, 'command is a required parameter' unless options.key? 'command'
              raise ArgumentError, 'user is a required parameter' unless options.key? 'user'
              raise ArgumentError, 'password is a required parameter' unless options.key? 'password'
    Severity: Minor
    Found in lib/fog/vsphere/requests/compute/vm_execute.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

    Avoid deeply nested control flow statements.
    Open

                    raise ArgumentError, 'commandList is required when using Sysprep identity and guiRunOnce' unless identity['Sysprep']['guiRunOnce'].key?('commandList')
    Severity: Major
    Found in lib/fog/vsphere/requests/compute/vm_clone.rb - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                          raise ArgumentError, 'SubnetMask is required when assigning static IPv6 when using nicSettingMap -> Adapter -> ipV6Spec' unless nic['adapter']['ipV6Spec'].key?('subnetMask')
      Severity: Major
      Found in lib/fog/vsphere/requests/compute/vm_clone.rb - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                          custom_spec['nicSettingMap'][0]['adapter']['dnsDomain'] = custom_spec['ipsettings']['domain'] if custom_spec['ipsettings'].key?('domain')
        Severity: Major
        Found in lib/fog/vsphere/requests/compute/vm_clone.rb - About 45 mins to fix

          Method traverse_raw_resource_pools has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

                  def traverse_raw_resource_pools(pools, rp)
                    if rp
                      if rp.respond_to? :resourcePool
                        traverse_raw_resource_pools(pools, rp.resourcePool)
                      end
          Severity: Minor
          Found in lib/fog/vsphere/requests/compute/list_resource_pools.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 vm_take_snapshot has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

                  def vm_take_snapshot(options = {})
                    raise ArgumentError, 'instance_uuid is a required parameter' unless options.key? 'instance_uuid'
                    raise ArgumentError, 'name is a required parameter' unless options.key? 'name'
                    defaults = {
                      description: '',
          Severity: Minor
          Found in lib/fog/vsphere/requests/compute/vm_take_snapshot.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

          Avoid deeply nested control flow statements.
          Open

                            custom_spec['nicSettingMap'] = [] unless custom_spec.key?('nicSettingMap')
          Severity: Major
          Found in lib/fog/vsphere/requests/compute/vm_clone.rb - About 45 mins to fix

            Method list_hosts has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                    def list_hosts(filters = {})
                      cluster = get_raw_cluster(filters[:cluster], filters[:datacenter])
            
                      results = property_collector_results(host_system_filter_spec(cluster))
            
            
            Severity: Minor
            Found in lib/fog/vsphere/requests/compute/list_hosts.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

            Avoid deeply nested control flow statements.
            Open

                              if custom_spec['ipsettings'].key?('ip') && !custom_spec['ipsettings'].key?('subnetMask')
                                raise ArgumentError, 'subnetMask is required for static ip'
                              end
            Severity: Major
            Found in lib/fog/vsphere/requests/compute/vm_clone.rb - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                              if identity['Sysprep']['licenseFilePrintData'].key?('autoUsers')
                                custom_licenseFilePrintData.autoUsers = identity['Sysprep']['licenseFilePrintData']['autoUsers'] if identity['Sysprep']['licenseFilePrintData']['autoMode'] == 'PerServer'
                              end
              Severity: Major
              Found in lib/fog/vsphere/requests/compute/vm_clone.rb - About 45 mins to fix

                Method list_compute_resources has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                        def list_compute_resources(filters = {})
                          datacenter_name = filters[:datacenter]
                          # default to show all compute_resources
                          only_active = filters[:effective] || false
                          compute_resources = raw_compute_resources datacenter_name
                Severity: Minor
                Found in lib/fog/vsphere/requests/compute/list_compute_resources.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 list_virtual_machines has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                        def list_virtual_machines(options = {})
                          if options['instance_uuid']
                            server = data[:servers][options['instance_uuid']]
                            server.nil? ? [] : [server]
                          elsif options['mo_ref']
                Severity: Minor
                Found in lib/fog/vsphere/requests/compute/list_virtual_machines.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

                Avoid deeply nested control flow statements.
                Open

                                raise ArgumentError, "Unsupported autoMode, supported modes are : 'perSeat' or 'perServer'" unless %w[perSeat perServer].include? identity['Sysprep']['licenseFilePrintData']['autoMode']
                Severity: Major
                Found in lib/fog/vsphere/requests/compute/vm_clone.rb - About 45 mins to fix

                  Consider simplifying this complex logical expression.
                  Open

                            if options.is_a? Fog::Vsphere::Compute::Interface
                              options
                  
                            else
                              raise ArgumentError, "Either key or name is a required parameter. options: #{options}" unless options.key?(:key) || options.key?(:mac) || options.key?(:name)
                  Severity: Major
                  Found in lib/fog/vsphere/requests/compute/list_vm_interfaces.rb - About 40 mins to fix

                    Method host_start_maintenance has 5 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                            def host_start_maintenance(name, cluster_name, datacenter_name, timeout = 0, evacuate_powered_off_vms = false)
                    Severity: Minor
                    Found in lib/fog/vsphere/requests/compute/host_start_maintenance.rb - About 35 mins to fix

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

                              def connect
                                # This is a state variable to allow digest validation of the SSL cert
                                bad_cert = false
                                loop do
                                  begin
                      Severity: Minor
                      Found in lib/fog/vsphere/compute.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 list_datastores has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                      Open

                              def list_datastores(filters = {})
                                datacenter_name = filters[:datacenter]
                                cluster_name = filters.fetch(:cluster, nil)
                                # default to show all datastores
                                only_active = filters[:accessible] || false
                      Severity: Minor
                      Found in lib/fog/vsphere/requests/compute/list_datastores.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 save has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                      Open

                              def save
                                raise Fog::Errors::Error, 'Resaving an existing object may create a duplicate' if persisted?
                                requires :server_id, :type, :network
                      
                                # Our approach of finding the newly created interface is rough.  We assume that the :key value always increments
                      Severity: Minor
                      Found in lib/fog/vsphere/models/compute/interface.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_controller has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                      Open

                              def create_controller(controller = nil, index = 0)
                                options = if controller
                                            controller_default_options.merge(controller.attributes)
                                          else
                                            controller_default_options
                      Severity: Minor
                      Found in lib/fog/vsphere/requests/compute/create_vm.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

                      Severity
                      Category
                      Status
                      Source
                      Language