torvalds/linux

View on GitHub
tools/testing/selftests/bpf/test_bpftool_synctypes.py

Summary

Maintainability
C
1 day
Test Coverage

File test_bpftool_synctypes.py has 486 lines of code (exceeds 250 allowed). Consider refactoring.
Open

#!/usr/bin/env python3
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
#
# Copyright (C) 2021 Isovalent, Inc.

Severity: Minor
Found in tools/testing/selftests/bpf/test_bpftool_synctypes.py - About 7 hrs to fix

    Function main has 65 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    def main():
        # No arguments supported at this time, but print usage for -h|--help
        argParser = argparse.ArgumentParser(description="""
        Verify that bpftool's code, help messages, documentation and bash
        completion are all in sync on program types, map types, attach types, and
    Severity: Major
    Found in tools/testing/selftests/bpf/test_bpftool_synctypes.py - About 2 hrs to fix

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

          def parse(self, pattern, end_marker):
              """
              Parse a block and return a set of values. Values to extract must be
              on separate lines in the file.
              @pattern: pattern used to identify the values to extract
      Severity: Minor
      Found in tools/testing/selftests/bpf/test_bpftool_synctypes.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 parse has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def parse(self):
              """
              Parse a block and return data as a dictionary. Items to extract must be
              on separate lines in the file.
              """
      Severity: Minor
      Found in tools/testing/selftests/bpf/test_bpftool_synctypes.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