trailofbits/protofuzz

View on GitHub

Showing 8 of 8 total issues

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

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

def _prototype_to_generator(descriptor, cls):
    """Return map of descriptor to a protofuzz generator."""
    _fd = D.FieldDescriptor
    generator = None

Severity: Minor
Found in protofuzz/protofuzz.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

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

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

    def find_protoc(path=os.environ["PATH"]):
        """Traverse a path ($PATH by default) to find the protoc compiler."""
        protoc_filenames = ["protoc", "protoc.exe"]
    
        bin_search_paths = path.split(os.pathsep) or []
    Severity: Minor
    Found in protofuzz/pbimport.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

    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 step_generator has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def step_generator(self, generators):
              if len(generators) < 1:
                  yield ()
              else:
                  first, rest = generators[0], generators[1:]
      Severity: Minor
      Found in protofuzz/gen.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 _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

      Severity
      Category
      Status
      Source
      Language