saltstack/salt

View on GitHub

Showing 9,400 of 17,590 total issues

Function image_snapshot_revert has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

def image_snapshot_revert(call=None, kwargs=None):
    '''
    Reverts an image state to a previous snapshot.

    .. versionadded:: 2016.3.0
Severity: Minor
Found in salt/cloud/clouds/opennebula.py - 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 ip_.is_private:
                        private_ips.append(adrs)
                    else:
                        public_ips.append(adrs)

Severity: Major
Found in salt/cloud/clouds/vagrant.py - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                        if device.deviceInfo.label in list(devices['disk'].keys()):
                            disk_spec = None
                            if 'size' in devices['disk'][device.deviceInfo.label]:
                                size_gb = float(devices['disk'][device.deviceInfo.label]['size'])
                                size_kb = int(size_gb * 1024.0 * 1024.0)
    Severity: Major
    Found in salt/cloud/clouds/vmware.py - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                          if master_supports_ipv6 and _valid_ip6(current_ip.ipAddress):
                              log.info(
                                  "[ %s ] Successfully retrieved IPv6 information "
                                  "in %s seconds", vm_ref.name, time_counter
                              )
      Severity: Major
      Found in salt/cloud/clouds/vmware.py - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                            if _valid_ip(current_ip.ipAddress) and not ipv4_address:
                                # Delay return in case we have a valid IPv6 available
                                ipv4_address = current_ip
                if ipv4_address:
        Severity: Major
        Found in salt/cloud/clouds/vmware.py - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                              if spec.device.deviceInfo.label == devices['cd'][cd_drive_label]['controller']:
                                  controller_key = spec.device.key
                                  ide_controllers[controller_key] = 0
                                  break
                      else:
          Severity: Major
          Found in salt/cloud/clouds/vmware.py - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                if hasattr(device, 'addressType'):
                                    device_full_info[device.deviceInfo.label]['addressType'] = device.addressType
            
            
            Severity: Major
            Found in salt/cloud/clouds/vmware.py - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                  if device.deviceInfo.label in list(devices['cd'].keys()):
                                      device_type = devices['cd'][device.deviceInfo.label]['device_type'] if 'device_type' in devices['cd'][device.deviceInfo.label] else ''
                                      mode = devices['cd'][device.deviceInfo.label]['mode'] if 'mode' in devices['cd'][device.deviceInfo.label] else ''
                                      iso_path = devices['cd'][device.deviceInfo.label]['iso_path'] if 'iso_path' in devices['cd'][device.deviceInfo.label] else ''
                                      cd_drive_spec = _edit_existing_cd_or_dvd_drive(device, device_type, mode, iso_path)
              Severity: Major
              Found in salt/cloud/clouds/vmware.py - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                                    if num_devices < 2:
                                        controller_key = ide_controller_key
                                        break
                
                
                Severity: Major
                Found in salt/cloud/clouds/vmware.py - About 45 mins to fix

                  Function show_storage_keys has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                  Open

                  def show_storage_keys(kwargs=None, conn=None, call=None):
                      '''
                      .. versionadded:: 2015.8.0
                  
                      Show storage account keys
                  Severity: Minor
                  Found in salt/cloud/clouds/msazure.py - 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

                  Function add_service_certificate has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                  Open

                  def add_service_certificate(kwargs=None, conn=None, call=None):
                      '''
                      .. versionadded:: 2015.8.0
                  
                      Add a new service certificate
                  Severity: Minor
                  Found in salt/cloud/clouds/msazure.py - 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

                  Function image_snapshot_flatten has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                  Open

                  def image_snapshot_flatten(call=None, kwargs=None):
                      '''
                      Flattens the snapshot of an image and discards others.
                  
                      .. versionadded:: 2016.3.0
                  Severity: Minor
                  Found in salt/cloud/clouds/opennebula.py - 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

                  Function secgroup_clone has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                  Open

                  def secgroup_clone(call=None, kwargs=None):
                      '''
                      Clones an existing security group.
                  
                      .. versionadded:: 2016.3.0
                  Severity: Minor
                  Found in salt/cloud/clouds/opennebula.py - 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

                  Function template_instantiate has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                  Open

                  def template_instantiate(call=None, kwargs=None):
                      '''
                      Instantiates a new virtual machine from a template.
                  
                      .. versionadded:: 2016.3.0
                  Severity: Minor
                  Found in salt/cloud/clouds/opennebula.py - 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 hasattr(device, 'device'):
                                          device_full_info[device.deviceInfo.label]['deviceKeys'] = device.device
                  
                  
                  Severity: Major
                  Found in salt/cloud/clouds/vmware.py - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                        if hasattr(device, 'videoRamSizeInKB'):
                                            device_full_info[device.deviceInfo.label]['videoRamSizeInKB'] = device.videoRamSizeInKB
                    
                    
                    Severity: Major
                    Found in salt/cloud/clouds/vmware.py - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                          if isinstance(device, vim.vm.device.VirtualDisk):
                                              device_full_info[device.deviceInfo.label]['capacityInKB'] = device.capacityInKB
                                              device_full_info[device.deviceInfo.label]['diskMode'] = device.backing.diskMode
                                              device_full_info[device.deviceInfo.label]['fileName'] = device.backing.fileName
                      
                      
                      Severity: Major
                      Found in salt/cloud/clouds/vmware.py - About 45 mins to fix

                        Function vn_free_ar has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                        Open

                        def vn_free_ar(call=None, kwargs=None):
                            '''
                            Frees a reserved address range from a virtual network.
                        
                            .. versionadded:: 2016.3.0
                        Severity: Minor
                        Found in salt/cloud/clouds/opennebula.py - 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

                        Function _get_ips has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                        Open

                        def _get_ips(node, addr_type='public'):
                            ret = []
                            for _, interface in node.addresses.items():
                                for addr in interface:
                                    if addr_type in ('floating', 'fixed') and addr_type == addr.get('OS-EXT-IPS:type'):
                        Severity: Minor
                        Found in salt/cloud/clouds/openstack.py - 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 spec.device.deviceInfo.label == devices['disk'][disk_label]['controller']:
                                                disk_spec.device.controllerKey = spec.device.key
                                                break
                        
                        
                        Severity: Major
                        Found in salt/cloud/clouds/vmware.py - About 45 mins to fix
                          Severity
                          Category
                          Status
                          Source
                          Language