saltstack/salt

View on GitHub

Showing 9,400 of 17,590 total issues

Avoid deeply nested control flow statements.
Open

                        if alias not in ret:
                            ret[alias] = {}
                        if driver not in ret[alias]:
Severity: Major
Found in salt/cloud/__init__.py - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                            if kwargs:
                                ret[alias][driver][vm_name] = self.clouds[fun](
                                    vm_name, kwargs, call='action'
                                )
                            else:
    Severity: Major
    Found in salt/cloud/__init__.py - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                              if 'id' in vm_details and vm_details['id'] in names:
                                  vm_name = vm_details['id']
                              else:
                                  log.debug(
                                      'vm:%s in provider:%s is not in name '
      Severity: Major
      Found in salt/cloud/__init__.py - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                                if name not in ret['create']:
                                    # Machine already removed
                                    break
        
        
        Severity: Major
        Found in salt/cloud/__init__.py - About 45 mins to fix

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

          def _parse_pricing(url, name):
              '''
              Download and parse an individual pricing file from AWS
          
              .. versionadded:: 2015.8.0
          Severity: Minor
          Found in salt/cloud/clouds/ec2.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 not isinstance(vm_details, dict):
                                      vm_details = {}
                                  if 'id' in vm_details and vm_details['id'] in names:
          Severity: Major
          Found in salt/cloud/__init__.py - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                    if driver not in ret[alias]:
                                        ret[alias][driver] = {}
            
                                    # Clean kwargs of "__pub_*" data before running the cloud action call.
                                    # Prevents calling positional "kwarg" arg before "call" when no kwarg
            Severity: Major
            Found in salt/cloud/__init__.py - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                      if overrides is None or isinstance(overrides, bool):
                                          # Foo:
                                          #   - bar1:
                                          #   - bar2:
                                          overrides = {}
              Severity: Major
              Found in salt/cloud/__init__.py - About 45 mins to fix

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

                def avail_images(conn=None):
                    '''
                    Return a dict of all available VM images on the cloud provider with
                    relevant data.
                
                
                Severity: Minor
                Found in salt/cloud/clouds/gce.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 invalid_functions.get(fun) is None:
                                            invalid_functions.update({fun: []})
                                        invalid_functions[fun].append(vm_name)
                Severity: Major
                Found in salt/cloud/__init__.py - About 45 mins to fix

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

                  def list_nodes(call=None):
                      ''' Return a list of the BareMetal servers that are on the provider.
                      '''
                      if call == 'action':
                          raise SaltCloudSystemExit(
                  Severity: Minor
                  Found in salt/cloud/clouds/scaleway.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 subnet_id is not None:
                                          return subnet_id
                  
                  
                  Severity: Major
                  Found in salt/cloud/clouds/ec2.py - About 45 mins to fix

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

                    def image_snapshot_delete(call=None, kwargs=None):
                        '''
                        Deletes a snapshot from the image.
                    
                        .. 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_clone has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                    Open

                    def template_clone(call=None, kwargs=None):
                        '''
                        Clones an existing virtual machine 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

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

                    def remove_host(kwargs=None, call=None):
                        '''
                        Remove the specified host system from this VMware environment
                    
                        CLI Example:
                    Severity: Minor
                    Found in salt/cloud/clouds/vmware.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, 'busNumber'):
                                            device_full_info[device.deviceInfo.label]['busNumber'] = device.busNumber
                    
                    
                    Severity: Major
                    Found in salt/cloud/clouds/vmware.py - About 45 mins to fix

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

                      def create_snapshot(name, kwargs=None, call=None):
                          '''
                          Create a snapshot of the specified virtual machine in this VMware
                          environment
                      
                      
                      Severity: Minor
                      Found in salt/cloud/clouds/vmware.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 device.unitNumber:
                                              device_full_info[device.deviceInfo.label]['unitNumber'] = device.unitNumber
                      
                      
                      Severity: Major
                      Found in salt/cloud/clouds/vmware.py - About 45 mins to fix

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

                        def image_persistent(call=None, kwargs=None):
                            '''
                            Sets the Image as persistent or not persistent.
                        
                            .. 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 device.deviceInfo.label in list(devices['scsi'].keys()):
                                                # Modify the existing SCSI controller
                                                scsi_controller_properties = devices['scsi'][device.deviceInfo.label]
                                                bus_sharing = scsi_controller_properties['bus_sharing'].strip().lower() if 'bus_sharing' in scsi_controller_properties else None
                                                if bus_sharing and bus_sharing in ['virtual', 'physical', 'no']:
                        Severity: Major
                        Found in salt/cloud/clouds/vmware.py - About 45 mins to fix
                          Severity
                          Category
                          Status
                          Source
                          Language