devdenh/python-project-lvl2

View on GitHub

Showing 5 of 5 total issues

Function make_tree has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

def make_tree(data1, data2):
    result = []
    for key in sorted(data1.keys() | data2.keys()):
        if (
                isinstance(data1.get(key), dict)
Severity: Minor
Found in gendiff/tree.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

Function to_str has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

def to_str(value):  # noqa  901
    bool_list = ['false', 'null', 'true', '0']
    for item in bool_list:
        if value == item:
            return value
Severity: Minor
Found in gendiff/formatters/plain.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

Function stringify has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

def stringify(data, depth):
    if isinstance(data, bool):
        return 'true' if data else 'false'
    if data is None:
        return 'null'
Severity: Minor
Found in gendiff/formatters/stylish.py - About 35 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 f"'{value}'"
Severity: Major
Found in gendiff/formatters/plain.py - About 30 mins to fix

    Avoid too many return statements within this function.
    Open

            return '[complex value]'
    Severity: Major
    Found in gendiff/formatters/plain.py - About 30 mins to fix
      Severity
      Category
      Status
      Source
      Language