saltstack/salt

View on GitHub

Showing 9,400 of 17,590 total issues

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

def _parse_os_release(*os_release_files):
    '''
    Parse os-release and return a parameter dictionary

    See http://www.freedesktop.org/software/systemd/man/os-release.html
Severity: Minor
Found in salt/grains/core.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 req_key == 'sls':
                            # Allow requisite tracking of entire sls files
                            if fnmatch.fnmatch(chunk['__sls__'], req_val):
                                found = True
                                reqs[r_state].append(chunk)
Severity: Major
Found in salt/state.py - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                            if req_key == 'sls':
                                # Allow requisite tracking of entire sls files
                                if fnmatch.fnmatch(chunk['__sls__'], req_val):
                                    if requisite == 'prereq':
                                        chunk['__prereq__'] = True
    Severity: Major
    Found in salt/state.py - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                              if saltenv != cenv:
                                  continue
                              log.debug(
      Severity: Major
      Found in salt/state.py - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                                for key, val in six.iteritems(arg):
                                    if key == 'names':
                                        for _name in val:
                                            if _name not in names:
                                                names.append(_name)
        Severity: Major
        Found in salt/state.py - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                                  if not found:
                                      continue
                              for lkey, lval in six.iteritems(listen_to):
          Severity: Major
          Found in salt/state.py - About 45 mins to fix

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

            def _virtual_hv(osdata):
                '''
                Returns detailed hypervisor information from sysfs
                Currently this seems to be used only by Xen
                '''
            Severity: Minor
            Found in salt/grains/core.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

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

              Avoid deeply nested control flow statements.
              Open

                                          if tgt not in top[saltenv]:
                                              top[saltenv][tgt] = ctop[saltenv][tgt]
                                              continue
                                          m_type1, m_states1 = _read_tgt(top[saltenv][tgt])
              Severity: Major
              Found in salt/state.py - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                                            if match_type is not None:
                                                merged.append(match_type)
                                            merged.extend(m_states1)
                Severity: Major
                Found in salt/state.py - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                          if not slsmod:
                                              errors.append(
                                                  'Environment {0} contains an empty sls '
                                                  'index'.format(saltenv)
                                              )
                  Severity: Major
                  Found in salt/state.py - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                                if isinstance(req_val, six.string_types):
                                                    if (fnmatch.fnmatch(chunk['name'], req_val) or
                                                        fnmatch.fnmatch(chunk['__id__'], req_val)):
                                                        if req_key == 'id' or chunk['state'] == req_key:
                                                            found = True
                    Severity: Major
                    Found in salt/state.py - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                              if req_ret['result'] is False:
                                                  # use SLS.ID for the key-- so its easier to find
                                                  key = '{sls}.{_id}'.format(sls=req_low['__sls__'],
                                                                              _id=req_low['__id__'])
                                                  failed_requisites.add(key)
                      Severity: Major
                      Found in salt/state.py - About 45 mins to fix

                        Avoid deeply nested control flow statements.
                        Open

                                                if state_data.get('source', '').endswith('/init.sls'):
                                                    p_comps.append('init')
                                                if level_count > len(p_comps):
                        Severity: Major
                        Found in salt/state.py - About 45 mins to fix

                          Avoid deeply nested control flow statements.
                          Open

                                                  if isinstance(arg, dict):
                                                      if arg:
                                                          if next(six.iterkeys(arg)) == 'order':
                                                              found = True
                                              if not found:
                          Severity: Major
                          Found in salt/state.py - About 45 mins to fix

                            Avoid deeply nested control flow statements.
                            Open

                                                    if req_ret is None:
                                                        continue
                                                    # If the result was False (not None) it was a failure
                                                    if req_ret['result'] is False:
                            Severity: Major
                            Found in salt/state.py - About 45 mins to fix

                              Avoid deeply nested control flow statements.
                              Open

                                                      if level_count > len(p_comps):
                                                          msg = ('Attempted relative include of \'{0}\' '
                                                                 'within SLS \'{1}:{2}\' '
                                                                 'goes beyond top level package '
                                                                 .format(inc_sls, saltenv, sls))
                              Severity: Major
                              Found in salt/state.py - About 45 mins to fix

                                Avoid deeply nested control flow statements.
                                Open

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

                                  Avoid deeply nested control flow statements.
                                  Open

                                                          if minion in active:
                                                              active.remove(minion)
                                                              if bwait:
                                                                  wait.append(datetime.now() + timedelta(seconds=bwait))
                                  Severity: Major
                                  Found in salt/cli/batch.py - About 45 mins to fix

                                    Avoid deeply nested control flow statements.
                                    Open

                                                            if low['retry']['splay'] != 0:
                                                                interval = interval + random.randint(0, low['retry']['splay'])
                                                            log.info(
                                    Severity: Major
                                    Found in salt/state.py - About 45 mins to fix
                                      Severity
                                      Category
                                      Status
                                      Source
                                      Language