torvalds/linux

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

Summary

Maintainability
C
7 hrs
Test Coverage

File kunit_kernel.py has 301 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# SPDX-License-Identifier: GPL-2.0
#
# Runs UML kernel, collects output, and handles errors.
#
# Copyright (C) 2019, Google LLC.
Severity: Minor
Found in tools/testing/kunit/kunit_kernel.py - About 3 hrs to fix

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

    def get_parsed_kunitconfig(build_dir: str,
                   kunitconfig_paths: Optional[List[str]]=None) -> kunit_config.Kconfig:
        if not kunitconfig_paths:
            path = get_kunitconfig_path(build_dir)
            if not os.path.exists(path):
    Severity: Minor
    Found in tools/testing/kunit/kunit_kernel.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 __init__ has 7 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def __init__(
    Severity: Major
    Found in tools/testing/kunit/kunit_kernel.py - About 50 mins to fix

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

          def __init__(
                self,
                build_dir: str,
                kunitconfig_paths: Optional[List[str]]=None,
                kconfig_add: Optional[List[str]]=None,
      Severity: Minor
      Found in tools/testing/kunit/kunit_kernel.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 run_kernel has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def run_kernel(self, args: Optional[List[str]]=None, build_dir: str='', filter_glob: str='', filter: str='', filter_action: Optional[str]=None, timeout: Optional[int]=None) -> Iterator[str]:
      Severity: Minor
      Found in tools/testing/kunit/kunit_kernel.py - About 45 mins to fix

        Function run_kernel has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            def run_kernel(self, args: Optional[List[str]]=None, build_dir: str='', filter_glob: str='', filter: str='', filter_action: Optional[str]=None, timeout: Optional[int]=None) -> Iterator[str]:
                if not args:
                    args = []
                if filter_glob:
                    args.append('kunit.filter_glob=' + filter_glob)
        Severity: Minor
        Found in tools/testing/kunit/kunit_kernel.py - About 35 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 make has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def make(self, jobs: int, build_dir: str, make_options: Optional[List[str]]) -> None:
                command = ['make', 'ARCH=' + self._linux_arch, 'O=' + build_dir, '--jobs=' + str(jobs)]
                if make_options:
                    command.extend(make_options)
                if self._cross_compile:
        Severity: Minor
        Found in tools/testing/kunit/kunit_kernel.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