saltstack/salt

View on GitHub
salt/utils/state.py

Summary

Maintainability
F
3 days
Test Coverage

Function search_onfail_requisites has a Cognitive Complexity of 103 (exceeds 5 allowed). Consider refactoring.
Open

def search_onfail_requisites(sid, highstate):
    '''
    For a particular low chunk, search relevant onfail related states
    '''
    onfails = []
Severity: Minor
Found in salt/utils/state.py - About 2 days 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_onfail_requisites has a Cognitive Complexity of 44 (exceeds 5 allowed). Consider refactoring.
Open

def check_onfail_requisites(state_id, state_result, running, highstate):
    '''
    When a state fail and is part of a highstate, check
    if there is onfail requisites.
    When we find onfail requisites, we will consider the state failed
Severity: Minor
Found in salt/utils/state.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 check_result has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

def check_result(running, recurse=False, highstate=None):
    '''
    Check the total return value of the run and determine if the running
    dict has any issues
    '''
Severity: Minor
Found in salt/utils/state.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 get_sls_opts has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

def get_sls_opts(opts, **kwargs):
    '''
    Return a copy of the opts for use, optionally load a local config on top
    '''
    opts = copy.deepcopy(opts)
Severity: Minor
Found in salt/utils/state.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 not isinstance(fchunk, list):
                        continue
                    else:
                        # bydefault onfail will fail, but you can
                        # set onfail_stop: False to prevent the highstate
Severity: Major
Found in salt/utils/state.py - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                        if '_|-' in rstateid:
                            st = salt.state.split_low_tag(rstateid)
                        # in case of simple state, try to guess
                        else:
                            id_ = rstate.get('__id__', rstateid)
    Severity: Major
    Found in salt/utils/state.py - About 45 mins to fix

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

      def merge_subreturn(original_return, sub_return, subkey=None):
          '''
          Update an existing state return (`original_return`) in place
          with another state return (`sub_return`), i.e. for a subresource.
      
      
      Severity: Minor
      Found in salt/utils/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 mod_ == st['state'] and fstate == st['__id__']:
                              ofresult = rstate.get('result', _empty)
                              if ofresult in [False, True]:
                                  nret = ofresult
                              if ofresult is False:
      Severity: Major
      Found in salt/utils/state.py - About 45 mins to fix

        There are no issues that match your filters.

        Category
        Status