fog/fog-vsphere

View on GitHub

Showing 128 of 128 total issues

Avoid deeply nested control flow statements.
Open

              raise ArgumentError, 'SysprepText -> value is required when using SysprepText identity' unless identity['SysprepText'].key?('value')
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

                        custom_spec['nicSettingMap'][0]['adapter']['gateway'] = custom_spec['ipsettings']['gateway'] if custom_spec['ipsettings'].key?('gateway')
      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']['subnetMask'] = custom_spec['ipsettings']['subnetMask'] if custom_spec['ipsettings'].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

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

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

                  class Mock
                    def list_vm_scsi_controllers(vm_id)
                      raise Fog::Vsphere::Compute::NotFound, 'VM not Found' unless data[:servers].key?(vm_id)
                      return [] unless data[:servers][vm_id].key?('scsi_controllers')
                      data[:servers][vm_id]['scsi_controllers'].map { |h| h.merge(server_id: vm_id) }
            Severity: Minor
            Found in lib/fog/vsphere/requests/compute/list_vm_scsi_controllers.rb and 1 other location - About 45 mins to fix
            lib/fog/vsphere/requests/compute/list_vm_cdroms.rb on lines 26..30

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

            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

            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

              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

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

                              class Mock
                                def list_vm_cdroms(vm_id)
                                  raise Fog::Vsphere::Compute::NotFound, 'VM not Found' unless data[:servers].key?(vm_id)
                                  return [] unless data[:servers][vm_id].key?('cdroms')
                                  data[:servers][vm_id]['cdroms'].map { |h| h.merge(instance_uuid: vm_id) }
                        Severity: Minor
                        Found in lib/fog/vsphere/requests/compute/list_vm_cdroms.rb and 1 other location - About 45 mins to fix
                        lib/fog/vsphere/requests/compute/list_vm_scsi_controllers.rb on lines 22..26

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

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

                            Severity
                            Category
                            Status
                            Source
                            Language