trailofbits/protofuzz

View on GitHub
protofuzz/values.py

Summary

Maintainability
B
5 hrs
Test Coverage

Function _fuzzdb_get_strings has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
Open

def _fuzzdb_get_strings(max_len: int = 0) -> Generator:
    """Return strings from fuzzdb."""
    ignored = ["integer-overflow"]
    for subdir in os.listdir(_get_fuzzdb_path()):
        if subdir in ignored:
Severity: Minor
Found in protofuzz/values.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

Avoid deeply nested control flow statements.
Open

                    if max_len != 0 and len(line) > max_len:
                        continue

Severity: Major
Found in protofuzz/values.py - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                        if not string or string.startswith("#"):
                            continue
                        if max_len != 0 and len(line) > max_len:
    Severity: Major
    Found in protofuzz/values.py - About 45 mins to fix

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

      def _get_fuzzdb_path() -> Path:
          """Configure the base path for fuzzdb file imports.
      
          fuzzdb is not a python module, so we cannot maximize the functionality
          of importlib to scan and import all of the files as resources. We instead
      Severity: Minor
      Found in protofuzz/values.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_integers has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

      def get_integers(bitwidth: int, unsigned: bool, limit: int = 0) -> Generator:
          """Return integers from fuzzdb database.
      
          bitwidth - The bitwidth that has to contain the integer
          unsigned - Whether the type is unsigned
      Severity: Minor
      Found in protofuzz/values.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