Skip to content

[lint-monster] os.Setenv refactoring: 4 findings #37726

@github-actions

Description

@github-actions

Summary

Custom linter has identified 4 findings where os.Setenv is used to mutate the process environment. This is an anti-pattern that makes code harder to test and reason about.

Root Cause

os.Setenv mutates the global process environment, which can:

  • Cause cross-test contamination
  • Make behavior harder to predict and test
  • Introduce global state dependencies

Affected Locations

  • pkg/cli/add_interactive_orchestrator.go:73 - os.Setenv usage
  • pkg/cli/engine_secrets.go:329 - os.Setenv usage
  • pkg/cli/engine_secrets.go:377 - os.Setenv usage
  • pkg/cli/engine_secrets.go:430 - os.Setenv usage

Remediation Strategy

Replace os.Setenv calls with explicit parameter passing:

  1. Identify what configuration is being set
  2. Pass it as a parameter or dependency injection
  3. Test the functions directly without environment mutations
  4. Run make golint-custom to validate fixes

Expected Outcome

All 4 findings resolved. Validate with:

make golint-custom | grep "os.Setenv"

Should return no matches.

Generated by 🧌 LintMonster · 139.7 AIC · ⌖ 4.37 AIC · ⊞ 19.9K ·

  • expires on Jun 14, 2026, 7:52 PM UTC-08:00

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions