saltstack/salt

View on GitHub

Showing 9,400 of 17,590 total issues

Avoid deeply nested control flow statements.
Open

                            if part['data']['id'] in minion_tracker[queue]['minions']:
                                minion_tracker[queue]['minions'].remove(part['data']['id'])
                            else:
                                salt.utils.stringutils.print_cli('minion {0} was already deleted from tracker, probably a duplicate key'.format(part['id']))
                        else:
Severity: Major
Found in salt/cli/batch.py - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                            if matches is None:
                                matches = []
                            # Resolve inc_sls in the specified environment
                            if env_key in matches or fnmatch.filter(self.avail[env_key], inc_sls):
    Severity: Major
    Found in salt/state.py - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                              for hind in range(len(high[name][state])):
                                  if isinstance(arg, six.string_types) and isinstance(high[name][state][hind], six.string_types):
                                      # replacing the function, replace the index
                                      high[name][state].pop(hind)
                                      high[name][state].insert(hind, arg)
      Severity: Major
      Found in salt/state.py - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                                if chunk.get('__prerequired__'):
                                    # Prereq recusive, run this chunk with prereq on
                                    if tag not in self.pre:
                                        low['__prereq__'] = True
                                        self.pre[ctag] = self.call(low, chunks, running)
        Severity: Major
        Found in salt/state.py - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                                      for tgt in targets:
                                          top[saltenv][tgt] = ctop[saltenv][tgt]
                                  except TypeError:
          Severity: Major
          Found in salt/state.py - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                    for val in six.itervalues(slsmod):
                                        if not val:
                                            errors.append(
                                                'Improperly formatted top file matcher '
                                                'in saltenv {0}: {1} file'.format(
            Severity: Major
            Found in salt/state.py - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                      if not resolved_envs:
                                          msg = ('Unknown include: Specified SLS {0}: {1} is not available on the salt '
                                                 'master in saltenv(s): {2} '
                                                 ).format(env_key,
                                                          inc_sls,
              Severity: Major
              Found in salt/state.py - About 45 mins to fix

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

                def get_bnum(opts, minions, quiet):
                    '''
                    Return the active number of minions to maintain
                    '''
                    partition = lambda x: float(x) / 100.0 * len(minions)
                Severity: Minor
                Found in salt/cli/batch.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 state == 'require' or state == 'watch':
                                            continue
                                        errors.append(
                Severity: Major
                Found in salt/state.py - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                          for fun in funcs:
                                              live['fun'] = fun
                                              chunks.append(live)
                                  else:
                  Severity: Major
                  Found in salt/state.py - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                            if not update:
                                                high[name][state].append(arg)
                            return high, errors
                    Severity: Major
                    Found in salt/state.py - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                              if not arg:
                                                  # Empty arg dict
                                                  # How did we get this far?
                                                  continue
                                              # Split out the components
                      Severity: Major
                      Found in salt/state.py - About 45 mins to fix

                        Avoid deeply nested control flow statements.
                        Open

                                                if req_val is None:
                                                    continue
                                                if req_key == 'sls':
                        Severity: Major
                        Found in salt/state.py - About 45 mins to fix

                          Avoid deeply nested control flow statements.
                          Open

                                                  if sls in done[saltenv]:
                                                      continue
                                                  tops[saltenv].append(
                          Severity: Major
                          Found in salt/state.py - About 45 mins to fix

                            Avoid deeply nested control flow statements.
                            Open

                                                    if env_key in matches or fnmatch.filter(self.avail[env_key], inc_sls):
                                                        resolved_envs = [env_key]
                                                    else:
                                                        resolved_envs = []
                                                else:
                            Severity: Major
                            Found in salt/state.py - About 45 mins to fix

                              Avoid deeply nested control flow statements.
                              Open

                                                      if isinstance(arg, six.string_types):
                                                          fun += 1
                                                          if ' ' in arg.strip():
                                                              errors.append(('The function "{0}" in state '
                                                              '"{1}" in SLS "{2}" has '
                              Severity: Major
                              Found in salt/state.py - About 45 mins to fix

                                Avoid deeply nested control flow statements.
                                Open

                                                        if req_val is None:
                                                            continue
                                                        if req_key == 'sls':
                                Severity: Major
                                Found in salt/state.py - About 45 mins to fix

                                  Avoid deeply nested control flow statements.
                                  Open

                                                              if isinstance(item, six.string_types):
                                                                  matches[saltenv].append(item)
                                                              elif isinstance(item, dict):
                                                                  env_key, inc_sls = item.popitem()
                                                                  if env_key not in self.avail:
                                  Severity: Major
                                  Found in salt/state.py - About 45 mins to fix

                                    Avoid deeply nested control flow statements.
                                    Open

                                                            if match:
                                                                levels, include = match.groups()
                                                            else:
                                                                msg = ('Badly formatted include {0} found in include '
                                                                        'in SLS \'{2}:{3}\''
                                    Severity: Major
                                    Found in salt/state.py - About 45 mins to fix

                                      Avoid deeply nested control flow statements.
                                      Open

                                                              if 'is not available' in error:
                                                                  # match SLS foobar in environment
                                                                  this_sls = 'SLS {0} in saltenv'.format(
                                                                      sls_match)
                                                                  if this_sls in error:
                                      Severity: Major
                                      Found in salt/state.py - About 45 mins to fix
                                        Severity
                                        Category
                                        Status
                                        Source
                                        Language