saltstack/salt

View on GitHub

Showing 9,400 of 17,590 total issues

Avoid deeply nested control flow statements.
Open

                            if 'kill' in pdat[key]:
                                return 'kill'
                        else:
Severity: Major
Found in salt/state.py - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                            if (fnmatch.fnmatch(chunk['name'], req_val) or
                                fnmatch.fnmatch(chunk['__id__'], req_val)):
                                if req_key == 'id' or chunk['state'] == req_key:
                                    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 == 'include':
                                  continue
                              elif saltenv != cenv:
                                  log.debug(
                                      'Section for saltenv \'%s\' in the \'%s\' '
      Severity: Major
      Found in salt/state.py - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                                    if ncnt > 5:
                                        break
                                    continue
        Severity: Major
        Found in salt/cli/batch.py - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                                  if retries == 1:
                                      ret['start_time'] = orig_ret['start_time']
                      else:
          Severity: Major
          Found in salt/state.py - About 45 mins to fix

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

                def _check_existing_archive(self):
                    '''
                    Check if archive exists or not. If exists and --force was not specified,
                    bail out. Otherwise remove it and move on.
            
            
            Severity: Minor
            Found in salt/cli/support/collector.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 not conf.get('salt.int.intfunc'):
                                        self.out.put('Collecting {}'.format(info.lower()), indent=2)
                                        self.collector.write(info, self._local_call(conf), output=output)
                                    else:
                                        self.collector.discard_current()
            Severity: Major
            Found in salt/cli/support/collector.py - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                      if isinstance(minion_id, dict):
                                          next_.append(minion_id.keys()[0])
                                      else:
                                          next_.append(minion_id)
              
              
              Severity: Major
              Found in salt/cli/batch.py - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                                        if key in disabled_reqs:
                                            log.warning('The %s requisite has been disabled, Ignoring.', key)
                                            continue
                                        rkey = key.split('_')[0]
                Severity: Major
                Found in salt/state.py - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                          for chunk in chunks:
                                              if chunk['__id__'] == listen_to or \
                                                 chunk['name'] == listen_to:
                                                  listen_to = {chunk['state']: chunk['__id__']}
                                                  found = True
                  Severity: Major
                  Found in salt/state.py - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                                if 'subfilter' in item:
                                                    _tmpdata = item.pop('subfilter')
                                                    for match, data in six.iteritems(_tmpdata):
                                                        _filter_matches(match, data, _opts)
                                                if isinstance(item, six.string_types):
                    Severity: Major
                    Found in salt/state.py - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                              if not isinstance(state[name][s_dec], list):
                                                  # quite certainly a syntax error, managed elsewhere
                                                  continue
                                              state[name][s_dec].append(
                      Severity: Major
                      Found in salt/state.py - About 45 mins to fix

                        Avoid deeply nested control flow statements.
                        Open

                                                if key not in req_in:
                                                    continue
                                                if key in disabled_reqs:
                        Severity: Major
                        Found in salt/state.py - About 45 mins to fix

                          Avoid deeply nested control flow statements.
                          Open

                                                  if isinstance(items, list):
                                                      # Formed as a list of requisite additions
                                                      hinges = []
                                                      for ind in items:
                                                          if not isinstance(ind, dict):
                          Severity: Major
                          Found in salt/state.py - About 45 mins to fix

                            Avoid deeply nested control flow statements.
                            Open

                                                    if isinstance(listvalue, dict):
                                                        # Search dict values in list for __slot__:
                                                        for key, value in listvalue.items():
                                                            try:
                                                                if value.startswith(SLOT_TEXT):
                            Severity: Major
                            Found in salt/state.py - About 45 mins to fix

                              Avoid deeply nested control flow statements.
                              Open

                                                      if isinstance(listvalue, six.text_type):
                                                          # Search strings in a list for __slot__:
                                                          if listvalue.startswith(SLOT_TEXT):
                                                              log.trace("Slot processsing nested string %s", listvalue)
                                                              cdata[atype][ind][idx] = self.__eval_slot(listvalue)
                              Severity: Major
                              Found in salt/state.py - About 45 mins to fix

                                Avoid deeply nested control flow statements.
                                Open

                                                            if minion not in parts:
                                                                parts[minion] = {}
                                                                parts[minion]['ret'] = {}
                                
                                
                                Severity: Major
                                Found in salt/cli/batch.py - About 45 mins to fix

                                  Avoid deeply nested control flow statements.
                                  Open

                                                              if value.startswith(SLOT_TEXT):
                                                                  log.trace("Slot processsing dict value %s", value)
                                                                  cdata[atype][ind][key] = self.__eval_slot(value)
                                                          except AttributeError:
                                  Severity: Major
                                  Found in salt/state.py - About 45 mins to fix

                                    Avoid deeply nested control flow statements.
                                    Open

                                                            for sls_target in sls_targets:
                                                                r_env = resolved_envs[0] if len(resolved_envs) == 1 else saltenv
                                                                mod_tgt = '{0}:{1}'.format(r_env, sls_target)
                                                                if mod_tgt not in mods:
                                                                    nstate, err = self.render_state(
                                    Severity: Major
                                    Found in salt/state.py - About 45 mins to fix

                                      Avoid deeply nested control flow statements.
                                      Open

                                                          with salt.utils.files.fopen('/proc/xen/capabilities') as fhr:
                                                              if 'control_d' not in fhr.read():
                                                                  # Tested on CentOS 5.5 / 2.6.18-194.3.1.el5xen
                                                                  grains['virtual_subtype'] = 'Xen PV DomU'
                                                              else:
                                      Severity: Major
                                      Found in salt/grains/core.py - About 45 mins to fix
                                        Severity
                                        Category
                                        Status
                                        Source
                                        Language