torvalds/linux

View on GitHub
tools/testing/kunit/kunit_parser.py

Summary

Maintainability
D
1 day
Test Coverage

File kunit_parser.py has 639 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# SPDX-License-Identifier: GPL-2.0
#
# Parses KTAP test results from a kernel dmesg log and incrementally prints
# results with reader-friendly format. Stores and returns test results in a
# Test object.
Severity: Major
Found in tools/testing/kunit/kunit_parser.py - About 1 day to fix

    Function isolate_ktap_output has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def isolate_ktap_output(kernel_output: Iterable[str]) \
                -> Iterator[Tuple[int, str]]:
            line_num = 0
            started = False
            for line in kernel_output:
    Severity: Minor
    Found in tools/testing/kunit/kunit_parser.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

    Function failed_names has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def failed_names(test: Test, parent_name: str) -> List[str]:
            # Note: we use 'main' internally for the top-level test.
            if not parent_name or parent_name == 'main':
                full_name = test.name
            else:
    Severity: Minor
    Found in tools/testing/kunit/kunit_parser.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

    Avoid too many return statements within this function.
    Open

            return TestStatus.SKIPPED
    Severity: Major
    Found in tools/testing/kunit/kunit_parser.py - About 30 mins to fix

      There are no issues that match your filters.

      Category
      Status