saltstack/salt

View on GitHub
salt/utils/minions.py

Summary

Maintainability
F
2 wks
Test Coverage

File minions.py has 971 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# -*- coding: utf-8 -*-
'''
This module contains routines used to verify the matcher against the minions
expected to return
'''
Severity: Major
Found in salt/utils/minions.py - About 2 days to fix

    Function _check_compound_minions has a Cognitive Complexity of 94 (exceeds 5 allowed). Consider refactoring.
    Open

        def _check_compound_minions(self,
                                    expr,
                                    delimiter,
                                    greedy,
                                    pillar_exact=False):  # pylint: disable=unused-argument
    Severity: Minor
    Found in salt/utils/minions.py - About 1 day 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 auth_check has a Cognitive Complexity of 46 (exceeds 5 allowed). Consider refactoring.
    Open

        def auth_check(self,
                       auth_list,
                       funs,
                       args,
                       tgt,
    Severity: Minor
    Found in salt/utils/minions.py - About 7 hrs 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 connected_ids has a Cognitive Complexity of 45 (exceeds 5 allowed). Consider refactoring.
    Open

        def connected_ids(self, subset=None, show_ip=False, show_ipv4=None, include_localhost=None):
            '''
            Return a set of all connected minion ids, optionally within a subset
            '''
            if include_localhost is not None:
    Severity: Minor
    Found in salt/utils/minions.py - About 6 hrs 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 spec_check has a Cognitive Complexity of 41 (exceeds 5 allowed). Consider refactoring.
    Open

        def spec_check(self, auth_list, fun, args, form):
            '''
            Check special API permissions
            '''
            if not auth_list:
    Severity: Minor
    Found in salt/utils/minions.py - About 6 hrs 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 auth_check_expanded has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring.
    Open

        def auth_check_expanded(self,
                                auth_list,
                                funs,
                                args,
                                tgt,
    Severity: Minor
    Found in salt/utils/minions.py - About 5 hrs 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 _check_ipcidr_minions has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
    Open

        def _check_ipcidr_minions(self, expr, greedy):
            '''
            Return the minions found by looking via ipcidr
            '''
            cache_enabled = self.opts.get('minion_data_cache', False)
    Severity: Minor
    Found in salt/utils/minions.py - About 4 hrs 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

    Cyclomatic complexity is too high in method _check_compound_minions. (38)
    Open

        def _check_compound_minions(self,
                                    expr,
                                    delimiter,
                                    greedy,
                                    pillar_exact=False):  # pylint: disable=unused-argument
    Severity: Minor
    Found in salt/utils/minions.py by radon

    Cyclomatic Complexity

    Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

    Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

    Construct Effect on CC Reasoning
    if +1 An if statement is a single decision.
    elif +1 The elif statement adds another decision.
    else +0 The else statement does not cause a new decision. The decision is at the if.
    for +1 There is a decision at the start of the loop.
    while +1 There is a decision at the while statement.
    except +1 Each except branch adds a new conditional path of execution.
    finally +0 The finally block is unconditionally executed.
    with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
    assert +1 The assert statement internally roughly equals a conditional statement.
    Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
    Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

    Source: http://radon.readthedocs.org/en/latest/intro.html

    Function nodegroup_comp has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
    Open

    def nodegroup_comp(nodegroup, nodegroups, skip=None, first_call=True):
        '''
        Recursively expand ``nodegroup`` from ``nodegroups``; ignore nodegroups in ``skip``
    
        If a top-level (non-recursive) call finds no nodegroups, return the original
    Severity: Minor
    Found in salt/utils/minions.py - About 4 hrs 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 __args_check has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
    Open

        def __args_check(self, valid, args=None, kwargs=None):
            '''
            valid is a dicts: {'args': [...], 'kwargs': {...}} or a list of such dicts.
            '''
            if not isinstance(valid, list):
    Severity: Minor
    Found in salt/utils/minions.py - About 4 hrs 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 _check_cache_minions has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
    Open

        def _check_cache_minions(self,
                                 expr,
                                 delimiter,
                                 greedy,
                                 search_type,
    Severity: Minor
    Found in salt/utils/minions.py - About 4 hrs 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

    CkMinions has 31 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class CkMinions(object):
        '''
        Used to check what minions should respond from a target
    
        Note: This is a best-effort set of the minions that would match a target.
    Severity: Minor
    Found in salt/utils/minions.py - About 3 hrs to fix

      Function __fun_check has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
      Open

          def __fun_check(self, valid, fun, args=None, kwargs=None):
              '''
              Check the given function name (fun) and its arguments (args) against the list of conditions.
              '''
              if not isinstance(valid, list):
      Severity: Minor
      Found in salt/utils/minions.py - About 2 hrs 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

      Cyclomatic complexity is too high in function nodegroup_comp. (24)
      Open

      def nodegroup_comp(nodegroup, nodegroups, skip=None, first_call=True):
          '''
          Recursively expand ``nodegroup`` from ``nodegroups``; ignore nodegroups in ``skip``
      
          If a top-level (non-recursive) call finds no nodegroups, return the original
      Severity: Minor
      Found in salt/utils/minions.py by radon

      Cyclomatic Complexity

      Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

      Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

      Construct Effect on CC Reasoning
      if +1 An if statement is a single decision.
      elif +1 The elif statement adds another decision.
      else +0 The else statement does not cause a new decision. The decision is at the if.
      for +1 There is a decision at the start of the loop.
      while +1 There is a decision at the while statement.
      except +1 Each except branch adds a new conditional path of execution.
      finally +0 The finally block is unconditionally executed.
      with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
      assert +1 The assert statement internally roughly equals a conditional statement.
      Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
      Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

      Source: http://radon.readthedocs.org/en/latest/intro.html

      Function mine_get has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
      Open

      def mine_get(tgt, fun, tgt_type='glob', opts=None):
          '''
          Gathers the data from the specified minions' mine, pass in the target,
          function to look up and the target type
          '''
      Severity: Minor
      Found in salt/utils/minions.py - About 2 hrs 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 fill_auth_list has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

          def fill_auth_list(self, auth_provider, name, groups, auth_list=None, permissive=None):
              '''
              Returns a list of authorisation matchers that a user is eligible for.
              This list is a combination of the provided personal matchers plus the
              matchers of any group the user is in.
      Severity: Minor
      Found in salt/utils/minions.py - About 1 hr 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

      Cyclomatic complexity is too high in method auth_check. (21)
      Open

          def auth_check(self,
                         auth_list,
                         funs,
                         args,
                         tgt,
      Severity: Minor
      Found in salt/utils/minions.py by radon

      Cyclomatic Complexity

      Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

      Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

      Construct Effect on CC Reasoning
      if +1 An if statement is a single decision.
      elif +1 The elif statement adds another decision.
      else +0 The else statement does not cause a new decision. The decision is at the if.
      for +1 There is a decision at the start of the loop.
      while +1 There is a decision at the while statement.
      except +1 Each except branch adds a new conditional path of execution.
      finally +0 The finally block is unconditionally executed.
      with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
      assert +1 The assert statement internally roughly equals a conditional statement.
      Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
      Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

      Source: http://radon.readthedocs.org/en/latest/intro.html

      Cyclomatic complexity is too high in method auth_check_expanded. (21)
      Open

          def auth_check_expanded(self,
                                  auth_list,
                                  funs,
                                  args,
                                  tgt,
      Severity: Minor
      Found in salt/utils/minions.py by radon

      Cyclomatic Complexity

      Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

      Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

      Construct Effect on CC Reasoning
      if +1 An if statement is a single decision.
      elif +1 The elif statement adds another decision.
      else +0 The else statement does not cause a new decision. The decision is at the if.
      for +1 There is a decision at the start of the loop.
      while +1 There is a decision at the while statement.
      except +1 Each except branch adds a new conditional path of execution.
      finally +0 The finally block is unconditionally executed.
      with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
      assert +1 The assert statement internally roughly equals a conditional statement.
      Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
      Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

      Source: http://radon.readthedocs.org/en/latest/intro.html

      Function _check_range_minions has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

          def _check_range_minions(self, expr, greedy):
              '''
              Return the minions found by looking via range expression
              '''
              if not HAS_RANGE:
      Severity: Minor
      Found in salt/utils/minions.py - About 1 hr 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 get_minion_data has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

      def get_minion_data(minion, opts):
          '''
          Get the grains/pillar for a specific minion.  If minion is None, it
          will return the grains/pillar for the first minion it finds.
      
      
      Severity: Minor
      Found in salt/utils/minions.py - About 1 hr 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 _pki_minions has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

          def _pki_minions(self):
              '''
              Retreive complete minion list from PKI dir.
              Respects cache if configured
              '''
      Severity: Minor
      Found in salt/utils/minions.py - About 1 hr 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 fill_auth_list_from_groups has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

          def fill_auth_list_from_groups(self, auth_provider, user_groups, auth_list):
              '''
              Returns a list of authorisation matchers that a user is eligible for.
              This list is a combination of the provided personal matchers plus the
              matchers of any group the user is in.
      Severity: Minor
      Found in salt/utils/minions.py - About 1 hr 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 show_ip:
                                  minions.add((id_, ipv6))
                              else:
                                  minions.add(id_)
                              break
      Severity: Major
      Found in salt/utils/minions.py - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                                    if isinstance(fun_kwargs, dict) and '__kwarg__' in fun_kwargs:
                                        fun_args = list(fun_args)  # copy on modify
                                        del fun_args[-1]
                                    else:
                                        fun_kwargs = None
        Severity: Major
        Found in salt/utils/minions.py - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                                  if self.__fun_check(ind[valid], fun_name, args.get('arg'), args.get('kwarg')):
                                      return True
                              if valid[1:] == form or valid == '@{0}s'.format(form):
          Severity: Major
          Found in salt/utils/minions.py - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                    if word == 'not':
                                        results.append('(')
                                        results.append(six.text_type(set(minions)))
                                        results.append('-')
                                        unmatched.append('-')
            Severity: Major
            Found in salt/utils/minions.py - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                      if decomposed:
                                          words = decomposed + words
                                      continue
              Severity: Major
              Found in salt/utils/minions.py - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                                            if self.__fun_check(ind[valid], fun, fun_args, fun_kwargs):
                                                return True
                        except TypeError:
                Severity: Major
                Found in salt/utils/minions.py - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                          if self.__fun_check(ind[valid], fun, args.get('arg'), args.get('kwarg')):
                                              return True
                          return False
                  Severity: Major
                  Found in salt/utils/minions.py - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                            if results[-1] == '(' and word in ('and', 'or'):
                                                log.error('Invalid beginning operator after "(": %s', word)
                                                return {'minions': [], 'missing': []}
                                            if word == 'not':
                    Severity: Major
                    Found in salt/utils/minions.py - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                              if word == 'not':
                                                  if not results[-1] in ('&', '|', '('):
                                                      results.append('&')
                                                  results.append('(')
                                                  results.append(six.text_type(set(minions)))
                      Severity: Major
                      Found in salt/utils/minions.py - About 45 mins to fix

                        Avoid deeply nested control flow statements.
                        Open

                                                if show_ip:
                                                    minions.add((id_, ipv4))
                                                else:
                                                    minions.add(id_)
                                                break
                        Severity: Major
                        Found in salt/utils/minions.py - About 45 mins to fix

                          Function match_check has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                          Open

                              def match_check(self, regex, fun):
                                  '''
                                  Validate a single regex to function comparison, the function argument
                                  can be a list of functions. It is all or nothing for a list of
                                  functions
                          Severity: Minor
                          Found in salt/utils/minions.py - About 35 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 check_minions has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                          Open

                              def check_minions(self,
                                                expr,
                                                tgt_type='glob',
                                                delimiter=DEFAULT_TARGET_DELIM,
                                                greedy=True):
                          Severity: Minor
                          Found in salt/utils/minions.py - About 35 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 too many return statements within this function.
                          Open

                                      return False
                          Severity: Major
                          Found in salt/utils/minions.py - About 30 mins to fix

                            Avoid too many return statements within this function.
                            Open

                                        return True
                            Severity: Major
                            Found in salt/utils/minions.py - About 30 mins to fix

                              Avoid too many return statements within this function.
                              Open

                                      return False
                              Severity: Major
                              Found in salt/utils/minions.py - About 30 mins to fix

                                Avoid too many return statements within this function.
                                Open

                                                return [joined]
                                Severity: Major
                                Found in salt/utils/minions.py - About 30 mins to fix

                                  Avoid too many return statements within this function.
                                  Open

                                                  return {'minions': minions, 'missing': missing}
                                  Severity: Major
                                  Found in salt/utils/minions.py - About 30 mins to fix

                                    Avoid too many return statements within this function.
                                    Open

                                                                return True
                                    Severity: Major
                                    Found in salt/utils/minions.py - About 30 mins to fix

                                      Avoid too many return statements within this function.
                                      Open

                                              return ret
                                      Severity: Major
                                      Found in salt/utils/minions.py - About 30 mins to fix

                                        Avoid too many return statements within this function.
                                        Open

                                                return {'minions': list(minions),
                                        Severity: Major
                                        Found in salt/utils/minions.py - About 30 mins to fix

                                          Avoid too many return statements within this function.
                                          Open

                                                  return False
                                          Severity: Major
                                          Found in salt/utils/minions.py - About 30 mins to fix

                                            Avoid too many return statements within this function.
                                            Open

                                                                    return {'minions': [], 'missing': []}
                                            Severity: Major
                                            Found in salt/utils/minions.py - About 30 mins to fix

                                              Avoid too many return statements within this function.
                                              Open

                                                                          return {'minions': [], 'missing': []}
                                              Severity: Major
                                              Found in salt/utils/minions.py - About 30 mins to fix

                                                Avoid too many return statements within this function.
                                                Open

                                                            return False
                                                Severity: Major
                                                Found in salt/utils/minions.py - About 30 mins to fix

                                                  Avoid too many return statements within this function.
                                                  Open

                                                          return False
                                                  Severity: Major
                                                  Found in salt/utils/minions.py - About 30 mins to fix

                                                    Avoid too many return statements within this function.
                                                    Open

                                                                                    return True
                                                    Severity: Major
                                                    Found in salt/utils/minions.py - About 30 mins to fix

                                                      Avoid too many return statements within this function.
                                                      Open

                                                                      return {'minions': [], 'missing': []}
                                                      Severity: Major
                                                      Found in salt/utils/minions.py - About 30 mins to fix

                                                        Similar blocks of code found in 4 locations. Consider refactoring.
                                                        Open

                                                                for fn_ in salt.utils.data.sorted_ignorecase(os.listdir(os.path.join(self.opts['pki_dir'], self.acc))):
                                                                    if not fn_.startswith('.') and os.path.isfile(os.path.join(self.opts['pki_dir'], self.acc, fn_)):
                                                                        mlist.append(fn_)
                                                        Severity: Major
                                                        Found in salt/utils/minions.py and 3 other locations - About 5 hrs to fix
                                                        salt/utils/minions.py on lines 246..257
                                                        salt/utils/minions.py on lines 286..288
                                                        salt/utils/minions.py on lines 443..445

                                                        Duplicated Code

                                                        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                        Tuning

                                                        This issue has a mass of 97.

                                                        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                        Refactorings

                                                        Further Reading

                                                        Similar blocks of code found in 4 locations. Consider refactoring.
                                                        Open

                                                                    for fn_ in salt.utils.data.sorted_ignorecase(os.listdir(os.path.join(self.opts['pki_dir'], self.acc))):
                                                                        if not fn_.startswith('.') and os.path.isfile(os.path.join(self.opts['pki_dir'], self.acc, fn_)):
                                                                            minions.append(fn_)
                                                        Severity: Major
                                                        Found in salt/utils/minions.py and 3 other locations - About 5 hrs to fix
                                                        salt/utils/minions.py on lines 246..257
                                                        salt/utils/minions.py on lines 443..445
                                                        salt/utils/minions.py on lines 688..690

                                                        Duplicated Code

                                                        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                        Tuning

                                                        This issue has a mass of 97.

                                                        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                        Refactorings

                                                        Further Reading

                                                        Similar blocks of code found in 4 locations. Consider refactoring.
                                                        Open

                                                                        for fn_ in salt.utils.data.sorted_ignorecase(os.listdir(os.path.join(self.opts['pki_dir'], self.acc))):
                                                                            if not fn_.startswith('.') and os.path.isfile(os.path.join(self.opts['pki_dir'], self.acc, fn_)):
                                                                                mlist.append(fn_)
                                                        Severity: Major
                                                        Found in salt/utils/minions.py and 3 other locations - About 5 hrs to fix
                                                        salt/utils/minions.py on lines 246..257
                                                        salt/utils/minions.py on lines 286..288
                                                        salt/utils/minions.py on lines 688..690

                                                        Duplicated Code

                                                        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                        Tuning

                                                        This issue has a mass of 97.

                                                        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                        Refactorings

                                                        Further Reading

                                                        Similar blocks of code found in 4 locations. Consider refactoring.
                                                        Open

                                                                    if self.opts['key_cache'] and os.path.exists(pki_cache_fn):
                                                                        log.debug('Returning cached minion list')
                                                                        if six.PY2:
                                                                            with salt.utils.files.fopen(pki_cache_fn) as fn_:
                                                                                return self.serial.load(fn_)
                                                        Severity: Major
                                                        Found in salt/utils/minions.py and 3 other locations - About 5 hrs to fix
                                                        salt/utils/minions.py on lines 286..288
                                                        salt/utils/minions.py on lines 443..445
                                                        salt/utils/minions.py on lines 688..690

                                                        Duplicated Code

                                                        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                        Tuning

                                                        This issue has a mass of 97.

                                                        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                        Refactorings

                                                        Further Reading

                                                        Identical blocks of code found in 2 locations. Consider refactoring.
                                                        Open

                                                            if isinstance(fun, six.string_types):
                                                                functions = list(set(fun.split(',')))
                                                                _ret_dict = len(functions) > 1
                                                            elif isinstance(fun, list):
                                                                functions = fun
                                                        Severity: Major
                                                        Found in salt/utils/minions.py and 1 other location - About 3 hrs to fix
                                                        salt/modules/mine.py on lines 311..318

                                                        Duplicated Code

                                                        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                        Tuning

                                                        This issue has a mass of 69.

                                                        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                        Refactorings

                                                        Further Reading

                                                        Identical blocks of code found in 2 locations. Consider refactoring.
                                                        Open

                                                                        if grains is None or proto not in grains:
                                                                            match = False
                                                                        elif isinstance(tgt, (ipaddress.IPv4Address, ipaddress.IPv6Address)):
                                                                            match = six.text_type(tgt) in grains[proto]
                                                                        else:
                                                        Severity: Major
                                                        Found in salt/utils/minions.py and 1 other location - About 3 hrs to fix
                                                        salt/matchers/ipcidr_match.py on lines 41..46

                                                        Duplicated Code

                                                        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                        Tuning

                                                        This issue has a mass of 62.

                                                        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                        Refactorings

                                                        Further Reading

                                                        Identical blocks of code found in 2 locations. Consider refactoring.
                                                        Open

                                                                    if tgt_type.lower() in ('pillar', 'pillar_pcre'):
                                                                        v_tgt_type = 'pillar_exact'
                                                                    elif tgt_type.lower() == 'compound':
                                                                        v_tgt_type = 'compound_pillar_exact'
                                                        Severity: Major
                                                        Found in salt/utils/minions.py and 1 other location - About 1 hr to fix
                                                        salt/utils/minions.py on lines 835..838

                                                        Duplicated Code

                                                        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                        Tuning

                                                        This issue has a mass of 42.

                                                        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                        Refactorings

                                                        Further Reading

                                                        Identical blocks of code found in 2 locations. Consider refactoring.
                                                        Open

                                                                if tgt_type.lower() in ('pillar', 'pillar_pcre'):
                                                                    v_tgt_type = 'pillar_exact'
                                                                elif tgt_type.lower() == 'compound':
                                                                    v_tgt_type = 'compound_pillar_exact'
                                                        Severity: Major
                                                        Found in salt/utils/minions.py and 1 other location - About 1 hr to fix
                                                        salt/utils/minions.py on lines 927..930

                                                        Duplicated Code

                                                        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                        Tuning

                                                        This issue has a mass of 42.

                                                        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                        Refactorings

                                                        Further Reading

                                                        Similar blocks of code found in 2 locations. Consider refactoring.
                                                        Open

                                                                        for ipv4 in grains.get('ipv4', []):
                                                                            if ipv4 in addrs:
                                                                                if show_ip:
                                                                                    minions.add((id_, ipv4))
                                                                                else:
                                                        Severity: Major
                                                        Found in salt/utils/minions.py and 1 other location - About 1 hr to fix
                                                        salt/utils/minions.py on lines 674..680

                                                        Duplicated Code

                                                        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                        Tuning

                                                        This issue has a mass of 50.

                                                        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                        Refactorings

                                                        Further Reading

                                                        Similar blocks of code found in 2 locations. Consider refactoring.
                                                        Open

                                                                        for ipv6 in grains.get('ipv6', []):
                                                                            if ipv6 in addrs:
                                                                                if show_ip:
                                                                                    minions.add((id_, ipv6))
                                                                                else:
                                                        Severity: Major
                                                        Found in salt/utils/minions.py and 1 other location - About 1 hr to fix
                                                        salt/utils/minions.py on lines 667..673

                                                        Duplicated Code

                                                        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                        Tuning

                                                        This issue has a mass of 50.

                                                        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                        Refactorings

                                                        Further Reading

                                                        Similar blocks of code found in 2 locations. Consider refactoring.
                                                        Open

                                                                        for match in set(self.check_minions(key, 'compound')):
                                                                            if match in auth_dictionary:
                                                                                auth_dictionary[match].extend(auth_list_entry[key])
                                                                            else:
                                                                                auth_dictionary[match] = auth_list_entry[key]
                                                        Severity: Major
                                                        Found in salt/utils/minions.py and 1 other location - About 1 hr to fix
                                                        salt/modules/zabbix.py on lines 2475..2479

                                                        Duplicated Code

                                                        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                        Tuning

                                                        This issue has a mass of 49.

                                                        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                        Refactorings

                                                        Further Reading

                                                        Similar blocks of code found in 2 locations. Consider refactoring.
                                                        Open

                                                                    if '127.0.0.1' in addrs:
                                                                        # Add in the address of a possible locally-connected minion.
                                                                        addrs.discard('127.0.0.1')
                                                                        addrs.update(set(salt.utils.network.ip_addrs(include_loopback=False)))
                                                        Severity: Minor
                                                        Found in salt/utils/minions.py and 1 other location - About 50 mins to fix
                                                        salt/utils/minions.py on lines 649..652

                                                        Duplicated Code

                                                        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                        Tuning

                                                        This issue has a mass of 44.

                                                        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                        Refactorings

                                                        Further Reading

                                                        Similar blocks of code found in 2 locations. Consider refactoring.
                                                        Open

                                                                    if '::1' in addrs:
                                                                        # Add in the address of a possible locally-connected minion.
                                                                        addrs.discard('::1')
                                                                        addrs.update(set(salt.utils.network.ip_addrs6(include_loopback=False)))
                                                        Severity: Minor
                                                        Found in salt/utils/minions.py and 1 other location - About 50 mins to fix
                                                        salt/utils/minions.py on lines 645..648

                                                        Duplicated Code

                                                        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                        Tuning

                                                        This issue has a mass of 44.

                                                        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                        Refactorings

                                                        Further Reading

                                                        There are no issues that match your filters.

                                                        Category
                                                        Status