avocado-framework/avocado

View on GitHub
avocado/utils/diff_validator.py

Summary

Maintainability
B
5 hrs
Test Coverage
B
84%

Function create_diff_report has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

def create_diff_report(change_diffs):
    """
    Pretty prints the output of the `change_diffs` variable.

    :param change_diffs: detected differences as groups of lines with filepath keys and a tuple of
Severity: Minor
Found in avocado/utils/diff_validator.py - About 2 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

Function parse_unified_diff_output has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

def parse_unified_diff_output(lines):
    """
    Parses the unified diff output of two files.

    :param lines: diff lines
Severity: Minor
Found in avocado/utils/diff_validator.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

Consider simplifying this complex logical expression.
Open

        if len(line) > 2 and (line[:3] == "+++" or line[:3] == "---"):
            continue
        # ignore line range information in the output
        elif len(line) > 1 and line[:2] == "@@":
            continue
Severity: Major
Found in avocado/utils/diff_validator.py - About 40 mins to fix

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

    def assert_change(actual_result, expected_result):
        """
        Condition wrapper of the upper method.
    
        :param actual_result: actual added and removed lines with filepath keys and a tuple of
    Severity: Minor
    Found in avocado/utils/diff_validator.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