Skip to content

Remove big_o_depth and is_recursive complexity metrics #1014

Closed

Description

@squid-protocol

Remove big_o_depth and is_recursive complexity metrics

Description

The big_o_depth and is_recursive metrics in the GitGalaxy SAST engine (gitgalaxy/core/detector.py) are fundamentally flawed and generate severe false positives. We need to completely remove both of these from the metrics schema and calculation pipeline.

Why they are broken

1. big_o_depth

This metric attempts to calculate algorithmic time complexity by counting indentation spaces. Every 4 spaces of indentation is mathematically treated as adding another magnitude of N, up to a hard cap of O(N^6). This is conceptually broken: an O(1) function that formats a long string across multiple lines, validates a deep JSON payload, or uses nested if blocks will be heavily indented, triggering massive false alarms. Algorithmic time complexity cannot be derived purely from whitespace geometry.

2. is_recursive

This metric flags a function as dangerously recursive O(2^N) by using a simple regex (\bname\b) to count if the function's own name appears inside its code block. This naive approach triggers on docstrings, comments, logging statements, and even standard object-oriented patterns like super().setUp(). True recursion detection across 50+ languages without an Abstract Syntax Tree (AST) is extremely fragile, and trying to salvage it with more regex will inevitably lead to more edge cases and false positives.

Action Items

  • Remove big_o_depth logic from gitgalaxy/core/detector.py.
  • Remove is_recursive logic from gitgalaxy/core/detector.py.
  • Remove both fields from the FunctionNode TypedDict in detector.py.
  • Update downstream aggregators in signal_processor.py and remove associated UI logic if present.

Activity

  1. added
    scope:frontier
    on Oct 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    scope:frontier

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions