saltstack/salt

View on GitHub

Showing 9,400 of 17,590 total issues

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

def ext_pillar(minion_id,
               pillar,  # pylint: disable=W0613
               url,
               with_grains=False):
    '''
Severity: Minor
Found in salt/pillar/http_json.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 isinstance(chg['diff'], six.string_types):
                        msg = 'File changed:\n{0}'.format(chg['diff'])
                if all([isinstance(x, dict) for x in six.itervalues(chg)]):
Severity: Major
Found in salt/state.py - About 45 mins to fix

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

    def ext_pillar(minion_id,
                   pillar,  # pylint: disable=W0613
                   url,
                   with_grains=False,
                   username=None,
    Severity: Minor
    Found in salt/pillar/http_yaml.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 type_name in type_specific_pillar_attributes:
                                type_specific_pillar_attribute = type_specific_pillar_attributes[type_name]
                            vmware_pillar[pillar_key] = dictupdate.update(vmware_pillar[pillar_key],
    Severity: Major
    Found in salt/pillar/vmware_pillar.py - About 45 mins to fix

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

          def compile_state_usage(self):
              '''
              Return all used and unused states for the minion based on the top match data
              '''
              err = []
      Severity: Minor
      Found in salt/state.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 funcs:
                                  for func in funcs:
                                      f_key = '{0}{1}'.format(
                                              mod,
                                              func[func.rindex('.'):]
      Severity: Major
      Found in salt/state.py - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                                for sub_sls in state.pop('include'):
                                    if isinstance(sub_sls, dict):
                                        sub_sls, v = next(six.iteritems(sub_sls))
                                        defaults = v.get('defaults', {})
                                        key = v.get('key', None)
        Severity: Major
        Found in salt/pillar/__init__.py - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                                  if ignore_missing:
                                      if saltenv not in self.ignored_pillars:
                                          self.ignored_pillars[saltenv] = []
                                      self.ignored_pillars[saltenv].extend(states.keys())
                                  top[saltenv][tgt] = matches
          Severity: Major
          Found in salt/pillar/__init__.py - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                    if not self.opts.get('pillar_includes_override_sls', False):
                                        # merge included state(s) with the current state
                                        # merged last to ensure that its values are
                                        # authoritative.
                                        include_states.append(state)
            Severity: Major
            Found in salt/pillar/__init__.py - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                  if all([('old' in x and 'new' in x)
                                          for x in six.itervalues(chg)]):
                                      msg = 'Made the following changes:\n'
                                      for pkg in chg:
                                          old = chg[pkg]['old']
              Severity: Major
              Found in salt/state.py - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                                        if isinstance(ctop[saltenv][tgt], six.string_types):
                                            ctop[saltenv][tgt] = [ctop[saltenv][tgt]]
                                        for comp in ctop[saltenv][tgt]:
                Severity: Major
                Found in salt/pillar/__init__.py - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                          if isinstance(entry, dict):
                                              low_name = next(six.iterkeys(entry))
                                              live['name'] = low_name
                                              list(map(live.update, entry[low_name]))
                                          else:
                  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

                                          for arg in high[nid][state]:
                                              if not isinstance(arg, dict):
                                                  continue
                                              if len(arg) != 1:
                                                  continue
                      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 isinstance(entry, dict):
                                                      low_name = next(six.iterkeys(entry))
                                                      live['name'] = low_name
                                                      list(map(live.update, entry[low_name]))
                                                  else:
                          Severity: Major
                          Found in salt/state.py - About 45 mins to fix

                            Avoid deeply nested control flow statements.
                            Open

                                                    if isinstance(items, dict):
                                                        # Formatted as a single req_in
                                                        for _state, name in six.iteritems(items):
                            
                                                            # Not a use requisite_in
                            Severity: Major
                            Found in salt/state.py - About 45 mins to fix

                              Avoid deeply nested control flow statements.
                              Open

                                                          if 'duration' in pdat[key]:
                                                              now = time.time()
                                                              if now - start > pdat[key]['duration']:
                                                                  return 'run'
                                                          if 'kill' in pdat[key]:
                              Severity: Major
                              Found in salt/state.py - About 45 mins to fix

                                Avoid deeply nested control flow statements.
                                Open

                                                        if not any(lkey == cref[0] and lval in cref for cref in crefs):
                                                            rerror = {_l_tag(lkey, lval):
                                                                      {
                                                                          'comment': 'Referenced state {0}: {1} does not exist'.format(lkey, lval),
                                                                          'name': 'listen_{0}:{1}'.format(lkey, lval),
                                Severity: Major
                                Found in salt/state.py - About 45 mins to fix

                                  Avoid deeply nested control flow statements.
                                  Open

                                                          for to_tag in to_tags:
                                                              if to_tag not in running:
                                                                  continue
                                                              if running[to_tag]['changes']:
                                                                  if not any(key[0] == cref[0] and key[1] in cref for cref in crefs):
                                  Severity: Major
                                  Found in salt/state.py - About 45 mins to fix
                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language