torvalds/linux

View on GitHub
scripts/checkkconfigsymbols.py

Summary

Maintainability
D
2 days
Test Coverage

Function print_undefined_symbols has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
Open

def print_undefined_symbols():
    """Main function of this module."""
    args = parse_options()

    global COLOR
Severity: Minor
Found in scripts/checkkconfigsymbols.py - About 5 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

File checkkconfigsymbols.py has 352 lines of code (exceeds 250 allowed). Consider refactoring.
Open

#!/usr/bin/env python3
# SPDX-License-Identifier: GPL-2.0-only

"""Find Kconfig symbols that are referenced but not defined."""

Severity: Minor
Found in scripts/checkkconfigsymbols.py - About 4 hrs to fix

    Function check_symbols_helper has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
    Open

    def check_symbols_helper(pool, ignore):
        """Helper method for check_symbols().  Used to catch keyboard interrupts in
        check_symbols() in order to properly terminate running worker processes."""
        source_files = []
        kconfig_files = []
    Severity: Minor
    Found in scripts/checkkconfigsymbols.py - About 3 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_kconfig_file has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

    def parse_kconfig_file(kfile):
        """Parse @kfile and update symbol definitions and references."""
        lines = []
        defined = []
        references = []
    Severity: Minor
    Found in scripts/checkkconfigsymbols.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 parse_options has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

    def parse_options():
        """The user interface of this module."""
        usage = "Run this tool to detect Kconfig symbols that are referenced but " \
                "not defined in Kconfig.  If no option is specified, "             \
                "checkkconfigsymbols defaults to check your current tree.  "       \
    Severity: Minor
    Found in scripts/checkkconfigsymbols.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 parse_source_file has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

    def parse_source_file(sfile):
        """Parse @sfile and return a list of referenced Kconfig symbols."""
        lines = []
        references = []
    
    
    Severity: Minor
    Found in scripts/checkkconfigsymbols.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 find_sims has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

    def find_sims(symbol, ignore, defined=[]):
        """Return a list of max. ten Kconfig symbols that are string-similar to
        @symbol."""
        if defined:
            return difflib.get_close_matches(symbol, set(defined), 10)
    Severity: Minor
    Found in scripts/checkkconfigsymbols.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

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

    def get_files():
        """Return a list of all files in the current git directory."""
        # use 'git ls-files' to get the worklist
        stdout = execute(["git", "ls-files"])
        if len(stdout) > 0 and stdout[-1] == "\n":
    Severity: Minor
    Found in scripts/checkkconfigsymbols.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

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

        if len(stdout) > 0 and stdout[-1] == "\n":
            stdout = stdout[:-1]
    Severity: Major
    Found in scripts/checkkconfigsymbols.py and 1 other location - About 1 hr to fix
    tools/testing/selftests/net/bpf_offload.py on lines 132..133

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 42.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

            if symbol == "FOO" or symbol == "BAR" or \
                    symbol == "FOO_BAR" or symbol == "XXX":
    Severity: Minor
    Found in scripts/checkkconfigsymbols.py and 1 other location - About 30 mins to fix
    tools/testing/selftests/tc-testing/plugin-lib/nsPlugin.py on lines 99..99

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 32.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    There are no issues that match your filters.

    Category
    Status