Repository navigation
Description
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_depthlogic fromgitgalaxy/core/detector.py. - Remove
is_recursivelogic fromgitgalaxy/core/detector.py. - Remove both fields from the
FunctionNodeTypedDict indetector.py. - Update downstream aggregators in
signal_processor.pyand remove associated UI logic if present.
Activity