saltstack/salt

View on GitHub

Showing 9,400 of 17,590 total issues

Avoid deeply nested control flow statements.
Open

                    if user not in changes['deny_perms']:
                        changes['deny_perms'][user] = {}
                    changes['deny_perms'][user]['perms'] = deny_perms
Severity: Major
Found in salt/states/file.py - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                        if __opts__['test']:
                            ret['comment'] += 'Cluster {0} is set to set up\n'.format(pcsclustername)
    
    
    Severity: Major
    Found in salt/states/pcs.py - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                          for perm in win_deny_perms[user]['perms']:
                              if not salt.utils.win_dacl.has_permission(
                                      name, user, perm, 'deny', exact=False):
                                  deny_perms.append(win_deny_perms[user]['perms'])
                      if deny_perms:
      Severity: Major
      Found in salt/states/file.py - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                            if not values_match or needs_changing:
                                # the old line always needs to go, so that will be
                                # reflected in the diff (this is the original line from
                                # the file being read)
                                diff.append('- {0}'.format(line))
        Severity: Major
        Found in salt/states/file.py - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                              if 'grant' in perms[user_name] and not perms[user_name]['grant']['inherited']:
                                  if 'remove_perms' not in changes:
                                      changes['remove_perms'] = {}
                                  changes['remove_perms'].update({user_name: perms[user_name]})
                          if user_name not in win_deny_perms:
          Severity: Major
          Found in salt/states/file.py - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                    for key in right:
                                        right[key] = six.text_type(right[key])
                                if sorted(kwargs['rights']) != sorted(usergroup['rights']):
            Severity: Major
            Found in salt/states/zabbix_usergroup.py - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                  if mdir.startswith(link, 0):
                                      log.debug(
                                          '** skipping empty dir ** %s, it intersects a '
                                          'symlink', mdir
                                      )
              Severity: Major
              Found in salt/states/file.py - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                                    if not salt.utils.win_dacl.has_permission(
                                            name, user, win_perms[user]['perms']):
                                        grant_perms = win_perms[user]['perms']
                                else:
                Severity: Major
                Found in salt/states/file.py - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                      if os.path.isdir(fn):
                                          if _is_child(fn, name):
                                              if fun == 'recurse':
                                                  fkeep = _gen_recurse_managed_files(**low)[3]
                                                  log.debug('Keep from %s: %s', fn, fkeep)
                  Severity: Major
                  Found in salt/states/file.py - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                        if salt.utils.platform.is_windows():
                                            ret['comment'] = ('Set ownership of symlink {0} to '
                                                              '{1}'.format(name, win_owner))
                                            ret['changes']['ownership'] = win_owner
                                        else:
                    Severity: Major
                    Found in salt/states/file.py - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                          if 'deny_perms' not in changes:
                                              changes['deny_perms'] = {}
                                          if user not in changes['deny_perms']:
                      Severity: Major
                      Found in salt/states/file.py - About 45 mins to fix

                        Avoid deeply nested control flow statements.
                        Open

                                            if did_uncomment:
                                                # irrespective of a value, if it was commented out and
                                                # changes are still to be made, then it needs to be
                                                # commented in
                                                if diff_count[key] > 0:
                        Severity: Major
                        Found in salt/states/file.py - About 45 mins to fix

                          Avoid deeply nested control flow statements.
                          Open

                                                  if salt.utils.platform.is_windows():
                                                      ret = __salt__['file.check_perms'](
                                                          path=full,
                                                          ret=ret,
                                                          owner=win_owner,
                          Severity: Major
                          Found in salt/states/file.py - About 45 mins to fix

                            Avoid deeply nested control flow statements.
                            Open

                                                if user is not None and user != stats.get('user'):
                                                    fchange['user'] = user
                                                if group is not None and group != stats.get('group'):
                            Severity: Major
                            Found in salt/states/file.py - About 45 mins to fix

                              Avoid deeply nested control flow statements.
                              Open

                                                  if fchange:
                                                      changes[path] = fchange
                              
                                  # Recurse skips root (we always do dirs, not root), so always check root:
                                  if not children_only:
                              Severity: Major
                              Found in salt/states/file.py - About 45 mins to fix

                                Avoid deeply nested control flow statements.
                                Open

                                                        if not exc.strerror.startswith('Path not found'):
                                                            errors.append(exc.strerror)
                                
                                
                                Severity: Major
                                Found in salt/states/file.py - About 45 mins to fix

                                  Avoid deeply nested control flow statements.
                                  Open

                                                          for acl_name in acl_names:
                                                              __salt__['acl.modfacl'](acl_type, acl_name, perms, name,
                                                                                      recursive=recurse, raise_err=True)
                                                          ret.update({'comment': 'Applied new permissions for '
                                  Severity: Major
                                  Found in salt/states/linux_acl.py - About 45 mins to fix

                                    Avoid deeply nested control flow statements.
                                    Open

                                                        if result.get('stderr'):
                                                            comments.append(result['stderr'])
                                                        ret['comment'] = '\n'.join(comments)
                                    Severity: Major
                                    Found in salt/states/kapacitor.py - About 45 mins to fix

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

                                      def present(name,
                                                  path,
                                                  mask,
                                                  cmd,
                                                  user='root'):
                                      Severity: Minor
                                      Found in salt/states/incron.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 deploy_resources has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                                      Open

                                          def deploy_resources(self, ret, api_key_required, lambda_integration_role, lambda_region, authorization_type):
                                              '''
                                              Method to deploy resources defined in the swagger file.
                                      
                                              ret
                                      Severity: Minor
                                      Found in salt/states/boto_apigateway.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