saltstack/salt

View on GitHub
salt/utils/saltclass.py

Summary

Maintainability
D
2 days
Test Coverage

Function expand_variables has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
Open

def expand_variables(a, b, expanded, path=None):
    if path is None:
        b = a.copy()
        path = []

Severity: Minor
Found in salt/utils/saltclass.py - About 3 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 expand_classes_in_order has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
Open

def expand_classes_in_order(minion_dict,
                            salt_data,
                            seen_classes,
                            expanded_classes,
                            classes_to_expand):
Severity: Minor
Found in salt/utils/saltclass.py - About 3 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 dict_search_and_replace has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
Open

def dict_search_and_replace(d, old, new, expanded):
    for (k, v) in six.iteritems(d):
        if isinstance(v, dict):
            dict_search_and_replace(d[k], old, new, expanded)

Severity: Minor
Found in salt/utils/saltclass.py - About 3 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

File saltclass.py has 307 lines of code (exceeds 250 allowed). Consider refactoring.
Wontfix

# -*- coding: utf-8 -*-
# Import Python libs
from __future__ import absolute_import, print_function, unicode_literals

import glob
Severity: Minor
Found in salt/utils/saltclass.py - About 3 hrs to fix

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

    def dict_merge(a, b, path=None):
        if path is None:
            path = []
    
        for key in b:
    Severity: Minor
    Found in salt/utils/saltclass.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 find_and_process_re has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

    def find_and_process_re(_str, v, k, b, expanded):
        vre = re.finditer(r'(^|.)\$\{.*?\}', _str)
        if vre:
            for re_v in vre:
                re_str = str(re_v.group())
    Severity: Minor
    Found in salt/utils/saltclass.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 expanded_dict_from_minion has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

    def expanded_dict_from_minion(minion_id, salt_data):
        _file = ''
        saltclass_path = salt_data['path']
        # Start
        for root, dirs, files in salt.utils.path.os_walk(os.path.join(saltclass_path, 'nodes'), followlinks=True):
    Severity: Minor
    Found in salt/utils/saltclass.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 i == old:
                            v[x] = new
                    x = x + 1
    Severity: Major
    Found in salt/utils/saltclass.py - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                          if isinstance(i, dict):
                              expand_variables(i, b, expanded, path + [str(k)])
                          if isinstance(i, six.string_types):
      Severity: Major
      Found in salt/utils/saltclass.py - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                            if isinstance(i, six.string_types):
                                b = find_and_process_re(i, v, k, b, expanded)
        
        
        Severity: Major
        Found in salt/utils/saltclass.py - About 45 mins to fix

          Function find_value_to_expand has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

          def find_value_to_expand(x, v):
              a = x
              for i in v[2:-1].split(':'):
                  if a is None:
                      return v
          Severity: Minor
          Found in salt/utils/saltclass.py - About 25 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 get_class has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

          def get_class(_class, salt_data):
              l_files = []
              saltclass_path = salt_data['path']
          
              straight, sub_init, sub_straight = get_class_paths(_class, saltclass_path)
          Severity: Minor
          Found in salt/utils/saltclass.py - About 25 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

          There are no issues that match your filters.

          Category
          Status