torvalds/linux

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

Summary

Maintainability
A
1 hr
Test Coverage

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

def parse_from_string(blob: str) -> Kconfig:
    """Parses a string containing Kconfig entries."""
    kconfig = Kconfig()
    is_not_set_matcher = re.compile(CONFIG_IS_NOT_SET_PATTERN)
    config_matcher = re.compile(CONFIG_PATTERN)
Severity: Minor
Found in tools/testing/kunit/kunit_config.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 is_subset_of has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def is_subset_of(self, other: 'Kconfig') -> bool:
        for name, value in self._entries.items():
            b = other._entries.get(name)
            if b is None:
                if value == 'n':
Severity: Minor
Found in tools/testing/kunit/kunit_config.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

There are no issues that match your filters.

Category
Status