Part of duplicate code analysis: #2754
Summary
internal/config/validation.go and internal/config/validation_env.go contain 30+ near-identical logValidation.Printf(...) calls following the same per-function lifecycle pattern: entry log → validation steps → "passed" or "failed" log. This creates noise and inconsistency without a shared format contract.
Duplication Details
Pattern: Entry/exit debug logging repeated per validation function
- Severity: Medium
- Occurrences: 30+ instances across 2 files
- Locations:
internal/config/validation.go (~28 instances)
internal/config/validation_env.go (~10 instances)
Code Sample — expandVariablesCore:
logValidation.Printf("Expanding variables: context=%s", contextDesc)
// ... logic ...
logValidation.Printf("Variable expansion completed: context=%s, undefined_count=%d",
contextDesc, len(undefinedVars))
Code Sample — validateServerConfigWithCustomSchemas:
logValidation.Printf("Validating server config: name=%s, type=%s", name, server.Type)
// ...
logValidation.Printf("Server type empty, defaulting to stdio: name=%s", name)
// ...
logValidation.Printf("Server config validation passed: name=%s", name)
This same structure — enter, log steps, exit with "passed"/"failed" — is repeated for every validation function.
Impact Analysis
- Maintainability: Log format inconsistencies have already crept in (some say "passed", others "completed", others "done")
- Bug Risk: Low — logging bugs are non-critical
- Code Bloat: ~30 one-liner log calls could be replaced with 3–5 shared helper calls
Refactoring Recommendations
- Create small logging helpers in
internal/config/ or reuse the existing logValidation logger:
func logValidateStart(name, typ string) {
logValidation.Printf("Validating server config: name=%s, type=%s", name, typ)
}
func logValidatePassed(name string) {
logValidation.Printf("Server config validation passed: name=%s", name)
}
func logValidateFailed(name, reason string) {
logValidation.Printf("Validation failed: name=%s, reason=%s", name, reason)
}
- Standardize log message vocabulary — pick one word per lifecycle event (e.g., always "passed", never "completed" or "done")
- Estimated effort: 1 hour
Implementation Checklist
Parent Issue
See parent analysis report: #2754
Related to #2754
Generated by Duplicate Code Detector · ◷
Part of duplicate code analysis: #2754
Summary
internal/config/validation.goandinternal/config/validation_env.gocontain 30+ near-identicallogValidation.Printf(...)calls following the same per-function lifecycle pattern: entry log → validation steps → "passed" or "failed" log. This creates noise and inconsistency without a shared format contract.Duplication Details
Pattern: Entry/exit debug logging repeated per validation function
internal/config/validation.go(~28 instances)internal/config/validation_env.go(~10 instances)Code Sample —
expandVariablesCore:Code Sample —
validateServerConfigWithCustomSchemas:This same structure — enter, log steps, exit with "passed"/"failed" — is repeated for every validation function.
Impact Analysis
Refactoring Recommendations
internal/config/or reuse the existinglogValidationlogger:Implementation Checklist
logValidation.Printfcalls in both filesmake test-unitto confirm no behavioral changesmake lintto verify formattingParent Issue
See parent analysis report: #2754
Related to #2754