refactor/introspect: split the git-style subcommand and flag parsers into helpers #91

Merged
pti merged 1 commit from refactor/complexity-introspect into main 2026-10-19 22:26:14 +02:00
Owner

Part of #71, the introspect slice. ParseSubcommands was at Sonar cognitive complexity 27 after #89 and ParseFlags at 36. ParseSubcommands now calls parseTwoColumnEntries, parseCommandBlocks and parseNameOnlyEntries, and ParseFlags uses gitFlag and addSimpleFlag. Before and after the change every parser entry point was dumped for every fixture under testdata, including the name-only catalog mode, and the dumps are identical. Existing parser tests and the fixture regression test from #89 pass untouched. 🤖 Generated with Claude Code

Part of #71, the introspect slice. ParseSubcommands was at Sonar cognitive complexity 27 after #89 and ParseFlags at 36. ParseSubcommands now calls parseTwoColumnEntries, parseCommandBlocks and parseNameOnlyEntries, and ParseFlags uses gitFlag and addSimpleFlag. Before and after the change every parser entry point was dumped for every fixture under testdata, including the name-only catalog mode, and the dumps are identical. Existing parser tests and the fixture regression test from #89 pass untouched. 🤖 Generated with Claude Code
refactor(introspect): split the git-style subcommand and flag parsers into helpers
All checks were successful
Lint / lint (pull_request) Successful in 56s
Lint / sonarqube (pull_request) Has been skipped
c2ce5dc9d5
GitParser.ParseSubcommands and ParseFlags exceeded Sonar's go:S3776
cognitive-complexity threshold of 25 (27 and 36), the former after #89
added the commands-block call and the name-only second pass.

ParseSubcommands now delegates pass one to parseTwoColumnEntries and the
AllowNameOnly pass, with its single-width purity rule, to
parseNameOnlyEntries. ParseFlags builds Flag values through gitFlag and
moves the simple-fallback match into addSimpleFlag. The long doc comment
explaining the purity bound stays on ParseSubcommands; the comments about
the established-width rule moved with the code they explain.

Behaviour-neutral: BestParseSubcommands, BestParseCatalog and BestParse
output over every file in testdata/ is byte-identical before and after.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
pti merged commit 11ad14b1a9 into main 2026-10-19 22:26:14 +02:00
pti deleted branch refactor/complexity-introspect 2026-10-19 22:26:15 +02:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
pti/wraptool!91
No description provided.