Kulakoff1988/python-project-lvl2

View on GitHub

Showing 2 of 2 total issues

Function build_ast_from_old_file has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

def build_ast_from_old_file(old_file, new_file, container_ast, path):
    for k, v in old_file.items():
        new_path = path + (k,)
        if k in new_file:
            new_value = new_file.get(k)
Severity: Minor
Found in gendiff/diff_getter/ast_builder.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 build_element has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

def build_element(key, node):
    result = []
    node_type = node.get('type')
    if node_type == UNCHANGED and node.get('children'):
        result.extend(get_diff_list(node.get('children')))
Severity: Minor
Found in gendiff/formatters/plain.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

Severity
Category
Status
Source
Language