fog/fog-vsphere

View on GitHub

Showing 94 of 130 total issues

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

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

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_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

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

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

              def initialize_scsi_controllers
                if attributes[:scsi_controllers].is_a?(Array) && !attributes[:scsi_controllers].empty?
                  attributes[:scsi_controllers].map! do |controller|
                    controller.is_a?(Hash) ? Fog::Vsphere::Compute::SCSIController.new(controller) : controller
                  end
      Severity: Minor
      Found in lib/fog/vsphere/models/compute/server.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

                      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

                          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

                          raise ArgumentError, 'licenseFilePrintData->autoMode is required when using Sysprep identity and licenseFilePrintData' unless identity['Sysprep']['licenseFilePrintData'].key?('autoMode')
          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'] = {} unless custom_spec['nicSettingMap'][0].key?('adapter')
            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

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

                            def create_controller(controller = nil, index = 0)
                              device_options = {}
                              options = if controller
                                          controller_default_options.merge(controller.attributes)
                                        else
                    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

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

                        def self.class_from_string(name, default_path = '')
                          const = default_path.empty? ? name.to_s : "#{default_path}::#{name}"
                          klass = const.split('::').inject(Object) { |m, c| m.const_get(c) }
                          return klass unless klass == Object
                        rescue NameError
                    Severity: Minor
                    Found in lib/fog/vsphere.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