refactor/config: split ApplyRequest and applyDefaults into helpers #95

Merged
pti merged 1 commit from refactor/complexity-config into main 2026-10-19 22:33:47 +02:00
Owner

Part of #71, the config slice. Merge this one first: applyDefaults crossed Sonar cognitive complexity 25 when #89 added the discover_depth default, and it is the single new-code issue failing the main quality gate right now. applyDefaults now delegates to applyMCPDefaults, applyToolDefaults and applyMCPServerDefaults with the copy, mutate, write-back loop semantics unchanged. ApplyRequest, at 39, delegates to checkDenyConflict, ensureAllowSeq, findRuleBySubcommand and mergeRuleFlags, deny check still first with the same text, validate then atomic write untouched. Reviewer pass dumped the defaulted Config for the scaffold and four hand-written configs and ran 24 ApplyRequest scenarios on main and on this branch, all byte-identical. No test changed. 🤖 Generated with Claude Code

Part of #71, the config slice. Merge this one first: applyDefaults crossed Sonar cognitive complexity 25 when #89 added the discover_depth default, and it is the single new-code issue failing the main quality gate right now. applyDefaults now delegates to applyMCPDefaults, applyToolDefaults and applyMCPServerDefaults with the copy, mutate, write-back loop semantics unchanged. ApplyRequest, at 39, delegates to checkDenyConflict, ensureAllowSeq, findRuleBySubcommand and mergeRuleFlags, deny check still first with the same text, validate then atomic write untouched. Reviewer pass dumped the defaulted Config for the scaffold and four hand-written configs and ran 24 ApplyRequest scenarios on main and on this branch, all byte-identical. No test changed. 🤖 Generated with Claude Code
refactor(config): split ApplyRequest and applyDefaults into helpers
All checks were successful
Lint / lint (pull_request) Successful in 1m6s
Lint / sonarqube (pull_request) Has been skipped
113f34049c
ApplyRequest's editConfig callback carried the deny-conflict check,
allow-sequence lookup/creation, rule search, and flag merge inline,
putting it above Sonar's go:S3776 threshold (issue #71). Extract
checkDenyConflict, ensureAllowSeq, findRuleBySubcommand (shared by the
deny and allow scans, which were identical loops) and mergeRuleFlags.

applyDefaults crossed the threshold when the DiscoverDepth default was
added. Split it per top-level block into applyMCPDefaults,
applyToolDefaults and applyMCPServerDefaults; the loops still copy the
struct, mutate the copy through a pointer, and write it back.

Behaviour-neutral: same evaluation order (deny check before any
mutation, validation and atomic write still in editConfig), identical
error strings and node mutations, and AddedFlags stays nil when
nothing is added.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
pti merged commit 6bf1b87047 into main 2026-10-19 22:33:47 +02:00
pti deleted branch refactor/complexity-config 2026-10-19 22:33:47 +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!95
No description provided.