refactor(doctor): introduce RunOptions and extract CheckVariables helpers - #847
Open
marcusburghardt wants to merge 1 commit into
Open
Conversation
…pers Replace the 9-parameter Run() signature with a RunOptions struct per AP-001 (Options struct pattern). This improves readability at the call site and makes the function extensible without signature changes. Extract three helpers from CheckVariables (complexity 38, CRAP Q4): - resolveEvaluatorTargets(): maps policy references to evaluator IDs via the dependency graph, collecting resolution failures and diagnostic results (~65 lines) - validateProviderVariables(): validates one provider's global and target variables against workspace config, producing a summary CheckResult with optional verbose detail (~75 lines) - buildVariableSummary(): constructs the pass/fail summary result for a single provider's variable validation (~40 lines) - buildVariableDetails(): generates verbose per-key status lines for a provider's variables (~55 lines) CheckVariables is now a ~35-line orchestrator that delegates to these focused helpers. All existing tests pass without modification, confirming behavioral equivalence. Item 4 (printDiagnostics writes to stdout) is already addressed by existing printDiagnosticsTo(w io.Writer) — no changes needed. Ref complytime#765 Assisted-by: OpenCode (claude-opus-4-6) Signed-off-by: Marcus Burghardt <maburgha@redhat.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Addresses #765 items 2, 3, and 4 (structural tech debt in doctor command).
Item 3:
Run()has 8 parameters (Architect MEDIUM)Replace the 9-parameter
Run()signature with aRunOptionsstruct perAP-001 (Options struct pattern). The old signature exceeded the 99-character
line limit; the new signature is
Run(opts RunOptions) []CheckResult.Item 2:
CheckVariablescomplexity 38 (Architect MEDIUM)Extract four focused helpers from
CheckVariables(was ~250 lines, CRAP Q4):resolveEvaluatorTargets()validateProviderVariables()buildVariableSummary()buildVariableDetails()CheckVariablesis now a ~35-line orchestrator that delegates to these helpers.Item 4:
printDiagnosticswrites to stdout (Architect LOW)Already addressed by existing
printDiagnosticsTo(w io.Writer)atcmd/complyctl/cli/doctor.go:388. No changes needed.Changes
internal/doctor/doctor.go:RunOptionsstruct,Run()signaturechange, four extracted helpers from
CheckVariablescmd/complyctl/cli/doctor.go: UpdatedrunDoctorcaller to constructRunOptionsstructVerification
make test-unit-- all existing tests pass without modification(behavioral equivalence confirmed)
make lint-- zero issuesRef #765