Repository navigation
Description
Summary
After #1477/PR #1478 corrected the audit tool's ground truth for dart constructors,
extra_functions is still 281 (func_precision 71.5%, was 68.7% pre-fix, real_functions 884).
This issue tracks four distinct, confirmed, real GitGalaxy dart func_start regex bugs
(not measurement artifacts) found while root-causing the remainder.
Corpus: language-crucible/data/dart/flutter/*.dart. Regex:
gitgalaxy/standards/language_standards.py's LANGUAGE_DEFINITIONS["dart"]["rules"]["func_start"].
Bug 1: const ClassName.name(...) named constructors are excluded entirely
flutter/theme_data.dart:700: const ThemeData.raw({...}) is never matched at all (confirmed:
absent from GitGalaxy's own function_data table when scanning this file directly). Contrast
with factory ThemeData.dark(...) (line 878), which is matched correctly.
Root cause: the regex has a negative lookahead directly before the name-capturing group that
unconditionally rejects any match where the preceding token is const (guarding against const someVar = value; / const someVar; variable declarations being mistaken for functions). This
blanket exclusion also blocks the legitimate const ClassName.name(...) constructor shape, which
is distinguishable from a const variable declaration by what follows the name: a constructor is
always followed by (, never by = or a bare ;.
Suggested fix shape: narrow the const-exclusion so it still rejects const IDENT = /const IDENT; but allows const IDENT( and const IDENT.IDENT( through, mirroring how the pattern
already lets factory through unconditionally.
Bug 2: colon-initializer, no-braced-body constructors confuse the brace-slicer
flutter/framework.dart:208: LabeledGlobalKey(this._debugLabel) : super.constructor(); --
a constructor with an initializer list and no {...} body at all (semicolon-terminated).
GitGalaxy's function_data row for this file has one entry named literally "Unknown_Block"
(gitgalaxy/core/detector.py's fallback name when no word token is found, lines ~3489/3558) with
loc=27 and calls_out_to including shortHash/describeIdentity/toString -- names that
actually belong to the next method (toString() at line 212-219), not this constructor.
This strongly suggests the func-body slicer, expecting every func_start match to be followed by a
{...} block, doesn't find one immediately after this constructor's ; and keeps scanning
forward until it hits the next method's {, merging the two into one bogus block and losing
the real name in the process.
Suggested fix shape: teach the slicer (or a dart-specific pre-check) that a func_start match
followed by : (colon, an initializer list) that terminates in ; before any { is a
complete, body-less declaration -- same category as C-family bodyless prototypes handled for
objective-c/rust in #1319/#1336, just a different trigger shape.
Bug 3: multi-line class header continuation lines misfire as func_start
flutter/editable_text.dart:2486-2487:
class EditableTextState extends State<EditableText>
with
AutomaticKeepAliveClientMixin<EditableText>,
...
implements AutofillClient {The continuation line implements AutofillClient { is matched on its own (func_start is
line-anchored) as if implements were a return type and AutofillClient a bare function name
followed immediately by {. Same shape confirmed for extends ContextAction<T> { continuation
lines elsewhere in the same file (e.g. line 6425).
Suggested fix shape: extend func_start's existing keyword-exclusion set (the same
(?:class|mixin|enum|extension|typedef|if|for|while|switch|catch|case|when|return|throw|new|var| final|const|Function) negative lookahead already present twice in the pattern) to also reject
when the token immediately preceding the "return type" position is implements/with/extends
appearing as the first token on the line -- these only appear in this position as class-header
continuations in dart, never as valid function-declaration prefixes.
Bug 4: multi-line bare call-site invocations still slip through the Invocation Shield
flutter/editable_text.dart:3048-3054 (and several similar sites, e.g. lines 2163-2182):
ContextMenuButtonItem(
type: ContextMenuButtonType.copy,
onPressed: ...,
),A bare call expression as a list-literal element, spanning multiple lines, misfires as a function
declaration named ContextMenuButtonItem. This is the same false-positive family as #1221's
"Invocation Shield" (bare call statements false-positive as function definitions) and #1428's
csharp "lambda arrow inside multi-line call arguments" -- dart already has some Invocation
Shield coverage (per #1221's 7-language batch), but this specific multi-line-call-as-list-element
shape still isn't caught.
Suggested fix shape: check whether dart's existing Invocation Shield logic in
gitgalaxy/core/detector.py handles multi-line call arguments the same way the csharp fix (#1428)
did (paren/bracket-depth-aware terminator scan) -- likely needs the equivalent treatment.
Scope note
This affects GitGalaxy's actual func_start extraction (epic #813's extraction-hardening scope),
not just measurement -- these are real false positives in production scans of dart code, not
audit-tool artifacts. All four are independently confirmed via direct regex/detector inspection
against real corpus source, not just audit-tool sample output.
Activity
fix(dart): 4 func_start false-positive shapes (const ctors, bodyless …
fix(dart): extend Invocation Shield to closure-typed call arguments (#…