saltstack/salt

View on GitHub
salt/utils/dictupdate.py

Summary

Maintainability
C
1 day
Test Coverage

Function update has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
Open

def update(dest, upd, recursive_update=True, merge_lists=False):
    '''
    Recursive version of the default dict.update

    Merges upd recursively into dest
Severity: Minor
Found in salt/utils/dictupdate.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 dictupdate.py has 286 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# -*- coding: utf-8 -*-
'''
Alex Martelli's soulution for recursive dict update from
http://stackoverflow.com/a/3233356
'''
Severity: Minor
Found in salt/utils/dictupdate.py - About 2 hrs to fix

    Function merge has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

    def merge(obj_a, obj_b, strategy='smart', renderer='yaml', merge_lists=False):
        if strategy == 'smart':
            if renderer.split('|')[-1] == 'yamlex' or renderer.startswith('yamlex_'):
                strategy = 'aggregate'
            else:
    Severity: Minor
    Found in salt/utils/dictupdate.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 ensure_dict_key has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    def ensure_dict_key(
            in_dict,
            keys,
            delimiter=DEFAULT_TARGET_DELIM,
            ordered_dict=False):
    Severity: Minor
    Found in salt/utils/dictupdate.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

    There are no issues that match your filters.

    Category
    Status