Repository navigation
Description
Remove db_complexity metric from the Structural Extractor
Description
The db_complexity metric in the GitGalaxy SAST engine (gitgalaxy/core/detector.py) is fundamentally flawed and generates severe false positives. It should be completely removed from the metrics schema and calculation pipeline.
Why it's broken
Currently, the "Database Complexity" score doesn't look for databases at all. It simply sums up basic regex signature hits for completely unrelated concepts, specifically:
io(weighted x3)serialization_parsing(weighted x2)state_mutation(weighted x1)
This means a function that simply does local variable reassignments (state_mutation) and prints heavily to standard out (io) will rack up a massive db_complexity score, even if absolutely no database or ORM is involved. The metric was implemented poorly and acts more like an AI hallucination than a valid heuristic.
Why we can't just fix it
To accurately measure computational database complexity (such as N+1 queries, deeply nested joins, or transaction boundaries), we would need an Abstract Syntax Tree (AST). Since GitGalaxy's engine operates natively across 50+ languages without compiling code (using fluid state counters, regex, and whitespace tracking), we are limited to structural heuristics.
Any AST-less regex approach to fixing this (e.g., looking for SELECT or .query() inside an indented loop) would just be another fragile heuristic measuring the volume or presence of database keywords, not true complexity. It would be highly error-prone (e.g., counting SQL strings that are defined inside a loop but executed safely outside of it) and would just replace one false-positive generator with another.
Action Items
- Remove
db_complexitycalculation from_calculate_block_metricsingitgalaxy/core/detector.py. - Remove
db_complexityfrom theFunctionNodeTypedDict indetector.py. - Ensure any downstream aggregators or visualizers in
signal_processor.pyor the UI drop this field.
Activity
Remove db_complexity metric from the Structural Extractor (#1021)
Remove big_o_depth and is_recursive complexity metrics from the risk …