saltstack/salt

View on GitHub

Showing 9,400 of 17,590 total issues

Avoid deeply nested control flow statements.
Open

                    if not enforce and prop in vmconfig['current'][collection]:
                        continue

                    # create set_ dict
                    if 'set_{0}'.format(collection) not in vmconfig['changed']:
Severity: Major
Found in salt/states/smartos.py - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                        if 'set_{0}'.format(collection) not in vmconfig['changed']:
                            vmconfig['changed']['set_{0}'.format(collection)] = {}
    
                        # add property to changeset
                        vmconfig['changed']['set_{0}'.format(collection)][prop] = vmconfig['state'][collection][prop]
    Severity: Major
    Found in salt/states/smartos.py - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                          if not isinstance(rret, (bool)) and 'Error' in rret:
                              ret['result'] = False
                              ret['comment'] = 'vm {0} updated, reprovision failed'.format(
                                  vmconfig['state']['hostname']
                              )
      Severity: Major
      Found in salt/states/smartos.py - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                                if key in medias_attr:
                                    medias_dict[med][key] = value
        
        
        Severity: Major
        Found in salt/states/zabbix_user.py - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                              if 'error' in updatemed:
                                  error.append(updatemed['error'])
          
          
          Severity: Major
          Found in salt/states/zabbix_user.py - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                if val is not None:
                                    vmconfig['state']['internal_metadata'][var] = val
            
                        # process add and update for collection
                        if collection in vmconfig['state'] and vmconfig['state'][collection] is not None:
            Severity: Major
            Found in salt/states/smartos.py - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                      if update_head:
                                          ret['changes']['revision'] = {
                                              'old': local_rev, 'new': remote_rev
                                          }
                                          if fast_forward is False:
              Severity: Major
              Found in salt/states/git.py - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                                    if instance in vmconfig['state'] and vmconfig['state'][instance] is not None:
                                        for state_cfg in vmconfig['state'][instance]:
                                            if vmconfig_type['instance'][instance] not in state_cfg:
                                                continue
                
                
                Severity: Major
                Found in salt/states/smartos.py - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                      if vmconfig['image_uuid'] not in res:
                                          ret['result'] = False
                                          ret['comment'] = 'failed to import image {0}'.format(vmconfig['image_uuid'])
                              else:
                  Severity: Major
                  Found in salt/states/smartos.py - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                        for cdisk in vmconfig['current']['disks']:
                                            if cdisk['path'].endswith(disk['path']):
                                                path = cdisk['path']
                                                break
                                    if not path:
                    Severity: Major
                    Found in salt/states/smartos.py - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                              for tag_name in deleted_tags:
                                                  try:
                                                      if not __opts__['test']:
                                                          __salt__['git.tag'](
                                                              target,
                      Severity: Major
                      Found in salt/states/git.py - About 45 mins to fix

                        Avoid deeply nested control flow statements.
                        Open

                                            for disk_id in [cache_disk_id] + capacity_disk_ids:
                                                __salt__['vsphere.erase_disk_partitions'](
                                                    disk_id=disk_id, service_instance=si)
                                            comments.append('Erased disks of diskgroup #{0}; '
                        Severity: Major
                        Found in salt/states/esxi.py - About 45 mins to fix

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

                          def move_config(name, xpath=None, where=None, dst=None, commit=False):
                              '''
                              Moves a XPATH value to a new location.
                          
                              Use the xpath parameter to specify the location of the object to be moved, the where parameter to
                          Severity: Minor
                          Found in salt/states/panos.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 vmconfig['state']['hostname'] in __salt__['vmadm.list'](order='hostname', search='state=running'):
                                                  kvm_needs_start = True
                                                  __salt__['vmadm.stop'](vm=vmconfig['state']['hostname'], key='hostname')
                          
                                      # do update
                          Severity: Major
                          Found in salt/states/smartos.py - About 45 mins to fix

                            Avoid deeply nested control flow statements.
                            Open

                                                    if branch not in all_local_branches:
                                                        actions.append(
                                                            'New branch \'{0}\' would be checked '
                                                            'out, with {1} as a starting '
                                                            'point'.format(branch, remote_loc)
                            Severity: Major
                            Found in salt/states/git.py - About 45 mins to fix

                              Avoid deeply nested control flow statements.
                              Open

                                                      if rev == 'HEAD':
                                                          checkout_rev = remote_rev
                                                      else:
                                                          checkout_rev = desired_upstream \
                                                              if desired_upstream \
                              Severity: Major
                              Found in salt/states/git.py - About 45 mins to fix

                                Avoid deeply nested control flow statements.
                                Open

                                                    for idx in six_range(0, len(local)):
                                                        for key in local[idx]:
                                                            local_val = local[idx][key]
                                                            remote_val = remote[idx].get(key)
                                                            if isinstance(local_val, six.string_types):
                                Severity: Major
                                Found in salt/states/azurearm_dns.py - About 45 mins to fix

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

                                  def subvolume_deleted(name, device, commit=False, __dest=None):
                                      '''
                                      Makes sure that a btrfs subvolume is removed.
                                  
                                      name
                                  Severity: Minor
                                  Found in salt/states/btrfs.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 configured_list.index(server) != i:
                                                          ret['changes']['Servers Reordered'].append(server)
                                                  else:
                                  Severity: Major
                                  Found in salt/states/win_dns_client.py - About 45 mins to fix

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

                                    def env_present(name,
                                                    value=None,
                                                    user='root'):
                                        '''
                                        Verifies that the specified environment variable is present in the crontab
                                    Severity: Minor
                                    Found in salt/states/cron.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

                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language