saltstack/salt

View on GitHub

Showing 9,400 of 17,590 total issues

Avoid deeply nested control flow statements.
Open

                    if "{0}".format(vmconfig['current'][prop]) == "{0}".format(vmconfig['state'][prop]):
                        continue

            # add property to changeset
            vmconfig['changed'][prop] = vmconfig['state'][prop]
Severity: Major
Found in salt/states/smartos.py - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

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

      Avoid deeply nested control flow statements.
      Open

                          if vmconfig['state']['hostname'] in __salt__['vmadm.list'](order='hostname', search='state=running'):
                              __salt__['vmadm.reboot'](vm=vmconfig['state']['hostname'], key='hostname')
                          if kvm_needs_start:
      Severity: Major
      Found in salt/states/smartos.py - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                                if not revs_match \
                                        and not update_head \
                                        and formatted_actions:
                                    ret['comment'] = formatted_actions
                                    return ret
        Severity: Major
        Found in salt/states/git.py - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                                  if exc.errno != errno.ENOENT:
                                      removal_errors[target_path] = exc
                          if removal_errors:
          Severity: Major
          Found in salt/states/git.py - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

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

              Avoid deeply nested control flow statements.
              Open

                                      if comments:
                                          msg += _format_comments(comments)
                                      return _neutral_test(ret, msg)
              Severity: Major
              Found in salt/states/git.py - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

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

                  Avoid deeply nested control flow statements.
                  Open

                                              if remote in remotes:
                                                  try:
                                                      # Do a rev-parse on <remote>/<rev> to get
                                                      # the local SHA1 for it, so we can compare
                                                      # it to the remote_rev SHA1.
                  Severity: Major
                  Found in salt/states/git.py - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                        if key not in safe_keys and key in optional_keys:
                                            if dic[key] == optional_keys[key]:
                                                del dic[key]
                    
                            # removes add on arguments from triggers
                    Severity: Major
                    Found in salt/states/win_task.py - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                          if not msg:
                                              msg = 'There was an error setting syslog config \'{0}\'. ' \
                                                    'Please check debug logs.'.format(key)
                                          ret['comment'] = msg
                      Severity: Major
                      Found in salt/states/esxi.py - About 45 mins to fix

                        Avoid deeply nested control flow statements.
                        Open

                                                if exc.errno != errno.ENOENT:
                                                    removal_errors[target_path] = exc
                                        if removal_errors:
                        Severity: Major
                        Found in salt/states/git.py - About 45 mins to fix

                          Avoid deeply nested control flow statements.
                          Open

                                                  if git_ver >= _LooseVersion('1.8.0'):
                                                      upstream_action = 'Tracking branch was unset'
                                                      branch_opts = ['--unset-upstream']
                                                  else:
                                                      branch_opts = None
                          Severity: Major
                          Found in salt/states/git.py - About 45 mins to fix

                            Avoid deeply nested control flow statements.
                            Open

                                                    if __opts__['test']:
                                                        changes['result'] = True
                                                        changes['comment'] = "Row will be update in " + table
                            
                                                    else:
                            Severity: Major
                            Found in salt/states/sqlite3.py - About 45 mins to fix

                              Avoid deeply nested control flow statements.
                              Open

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

                                Avoid deeply nested control flow statements.
                                Open

                                                    if kvm_needs_start:
                                                        __salt__['vmadm.start'](vm=vmconfig['state']['hostname'], key='hostname')
                                            else:
                                Severity: Major
                                Found in salt/states/smartos.py - About 45 mins to fix

                                  Avoid deeply nested control flow statements.
                                  Open

                                                          if __salt__['git.symbolic_ref'](
                                                                  target,
                                                                  'HEAD',
                                                                  opts=['--quiet'],
                                                                  user=user,
                                  Severity: Major
                                  Found in salt/states/git.py - About 45 mins to fix

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

                                    def table_absent(name, db):
                                        '''
                                        Make sure the specified table does not exist
                                    
                                        name
                                    Severity: Minor
                                    Found in salt/states/sqlite3.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 'error' in deletedmed:
                                                            error.append(deletedmed['error'])
                                    
                                    
                                    Severity: Major
                                    Found in salt/states/zabbix_user.py - About 45 mins to fix

                                      Avoid deeply nested control flow statements.
                                      Open

                                                          if prop in vmconfig['current'][collection] and \
                                                              vmconfig['current'][collection][prop] == vmconfig['state'][collection][prop]:
                                                              continue
                                      
                                                          # skip update if not enforcing
                                      Severity: Major
                                      Found in salt/states/smartos.py - About 45 mins to fix
                                        Severity
                                        Category
                                        Status
                                        Source
                                        Language