saltstack/salt

View on GitHub
salt/runners/vault.py

Summary

Maintainability
A
3 hrs
Test Coverage

Function generate_token has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

def generate_token(minion_id, signature, impersonated_by_master=False):
    '''
    Generate a Vault token for minion minion_id

    minion_id
Severity: Minor
Found in salt/runners/vault.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 _expand_pattern_lists has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

def _expand_pattern_lists(pattern, **mappings):
    '''
    Expands the pattern for any list-valued mappings, such that for any list of
    length N in the mappings present in the pattern, N copies of the pattern are
    returned, each with an element of the list substituted.
Severity: Minor
Found in salt/runners/vault.py - About 55 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 {'error': six.text_type(e)}
Severity: Major
Found in salt/runners/vault.py - About 30 mins to fix

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

    def _get_policies(minion_id, config):
        '''
        Get the policies that should be applied to a token for minion_id
        '''
        _, grains, _ = salt.utils.minions.get_minion_data(minion_id, __opts__)
    Severity: Minor
    Found in salt/runners/vault.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