KarrLab/wc_utils

View on GitHub
wc_utils/util/dict.py

Summary

Maintainability
A
3 hrs
Test Coverage
B
81%

Function expand_dict has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    def expand_dict(d, separator='.'):
        """ Expand a dict, converting string or tuple keys into nested keys

        Args:
            d (:obj:`dict`): dictionary to expand
Severity: Minor
Found in wc_utils/util/dict.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 flatten_dict has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    def flatten_dict(d, root_flat_key=None):
        """ Flatten a dict, converting nested keys into tuples

        Args:
            d (:obj:`dict`): dictionary to flatten
Severity: Minor
Found in wc_utils/util/dict.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 set_value has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def set_value(d, target_key, new_value, match_type=True):
        """ Set values of target keys in a nested dictionary

        Consider every `key`-`value` pair in nested dictionary `d`. If `value` is not a `dict`,
        and `key` is equal to `target_key` then replace `value` with `new_value`. However, if
Severity: Minor
Found in wc_utils/util/dict.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