You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
internal/cmd/flags_difc.go and internal/cmd/flags_logging.go together contain 9 trivial one-to-two-line getDefault*() functions that each wrap a single os.Getenv() or envutil.Get*() call. While each function is individually small, the pattern is repeated identically across both files and could be consolidated with a shared helper.
Duplication Details
Pattern: Single-Expression getDefault*() Wrappers
Severity: Medium
Occurrences: 9 near-identical functions (5 in flags_difc.go, 4 in flags_logging.go)
Applicable to the 5 trivial os.Getenv() wrappers in flags_difc.go
Estimated effort: 15 minutes
Benefits: Removes 15+ lines of boilerplate; env var name is visible at the registration site
Alternative: Keep as named functions (acceptable if the team values named functions for documentation purposes — they make the flag default source explicit in the code).
Note: getDefaultDIFCMode() (lines 41–51) is intentionally more complex with validation logic — it should remain as a named function regardless.
Implementation Checklist
Decide: inline or keep named getters (team preference)
If inlining: replace 5 trivial os.Getenv() wrappers in flags_difc.go
If inlining: verify call sites are updated
Run make test to verify no regressions
Parent Issue
See parent analysis report: #2361
Related to #2361
Part of duplicate code analysis: #2361
Summary
internal/cmd/flags_difc.goandinternal/cmd/flags_logging.gotogether contain 9 trivial one-to-two-linegetDefault*()functions that each wrap a singleos.Getenv()orenvutil.Get*()call. While each function is individually small, the pattern is repeated identically across both files and could be consolidated with a shared helper.Duplication Details
Pattern: Single-Expression
getDefault*()Wrappersflags_difc.go, 4 inflags_logging.go)internal/cmd/flags_difc.golines 63–85:internal/cmd/flags_logging.golines 35–55:Impact Analysis
os.Getenv()calls at the call site, or by a shared helperRefactoring Recommendations
Inline trivial getters directly at the flag registration call site (since they are only called once):
os.Getenv()wrappers inflags_difc.goAlternative: Keep as named functions (acceptable if the team values named functions for documentation purposes — they make the flag default source explicit in the code).
Note:
getDefaultDIFCMode()(lines 41–51) is intentionally more complex with validation logic — it should remain as a named function regardless.Implementation Checklist
os.Getenv()wrappers inflags_difc.gomake testto verify no regressionsParent Issue
See parent analysis report: #2361
Related to #2361
Warning
The following domain was blocked by the firewall during workflow execution:
proxy.golang.orgTo allow these domains, add them to the
network.allowedlist in your workflow frontmatter:See Network Configuration for more information.