tools/testing/kunit/kunit_parser.py
File kunit_parser.py
has 639 lines of code (exceeds 250 allowed). Consider refactoring. Open
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.
Function isolate_ktap_output
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
Open
def isolate_ktap_output(kernel_output: Iterable[str]) \
-> Iterator[Tuple[int, str]]:
line_num = 0
started = False
for line in kernel_output:
- Read upRead up
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
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:
- Read upRead up
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
Open
return TestStatus.SKIPPED