Skip to content

fix: resolve osgetenvlibrary lint findings in boundary-layer packages#42163

Merged
pelikhan merged 2 commits into
mainfrom
copilot/lint-monster-refactor-environment-coupling
Jun 29, 2026
Merged

fix: resolve osgetenvlibrary lint findings in boundary-layer packages#42163
pelikhan merged 2 commits into
mainfrom
copilot/lint-monster-refactor-environment-coupling

Conversation

Copilot AI commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

The osgetenvlibrary custom linter flagged 13 os.Getenv calls across 7 library packages. All affected call sites are already at the outermost practical boundary — functions whose explicit purpose is to read environment configuration — so the fix is either suppression with //nolint:osgetenvlibrary or consolidation onto an existing helper.

Changes

  • pkg/logger/logger.go — nolint on initDebugEnv() and the debugColors package-var init; these are the init-time env-read boundary for the logger package
  • pkg/console/accessibility.go — nolint on each os.Getenv in IsAccessibleMode(); this function is the accessibility env boundary
  • pkg/console/spinner.go — replace direct os.Getenv("ACCESSIBLE") with IsAccessibleMode(), which already consolidates ACCESSIBLE, TERM=dumb, and NO_COLOR; removes the coupling and aligns behavior with the canonical helper
  • pkg/constants/constants.go — nolint in GetWorkflowDir() (GH_AW_WORKFLOWS_DIR override)
  • pkg/envutil/envutil.go — nolint in GetIntFromEnv(); this utility is the env-reading abstraction
  • pkg/github/label_objective_mapping.go — nolint in LoadObjectiveMappingFromConfig() (OBJECTIVE_MAPPING_JSON override)
  • pkg/parser/github.go — nolint in GetGitHubHost() and GetGitHubToken(); both are purpose-built env-to-config boundary functions
// Before: spinner duplicated the check
isAccessible := os.Getenv("ACCESSIBLE") != ""

// After: uses the canonical boundary helper
isAccessible := IsAccessibleMode()

Resolves 13 environment-coupling findings from the osgetenvlibrary
custom linter. For call sites that ARE the outermost boundary layer
(init functions, dedicated env-reading helpers, config-loading
functions), add //nolint:osgetenvlibrary. For spinner.go, replace the
duplicate os.Getenv("ACCESSIBLE") call with the existing IsAccessibleMode()
helper instead.

Files changed:
- pkg/logger/logger.go: nolint initDebugEnv + debugColors (3 findings)
- pkg/console/accessibility.go: nolint IsAccessibleMode (3 findings)
- pkg/console/spinner.go: use IsAccessibleMode() instead of os.Getenv (1 finding)
- pkg/constants/constants.go: nolint GetWorkflowDir (1 finding)
- pkg/envutil/envutil.go: nolint GetIntFromEnv (1 finding)
- pkg/github/label_objective_mapping.go: nolint LoadObjectiveMappingFromConfig (1 finding)
- pkg/parser/github.go: nolint GetGitHubHost/GetGitHubToken (3 findings)

Closes #42160

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Refactor environment-coupling custom lints fix: resolve osgetenvlibrary lint findings in boundary-layer packages Jun 29, 2026
Copilot AI requested a review from pelikhan June 29, 2026 04:07
@pelikhan pelikhan marked this pull request as ready for review June 29, 2026 05:08
Copilot AI review requested due to automatic review settings June 29, 2026 05:08
@github-actions

github-actions Bot commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Test Quality Sentinel completed test quality analysis.

No test files were added or modified in this PR. Test Quality Sentinel skipped. PR #42163 only contains production code changes (os.Getenv → envutil.Getenv lint fixes in 7 boundary-layer packages with no accompanying test additions or modifications).

@github-actions

github-actions Bot commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

PR Code Quality Reviewer completed the code quality review.

@github-actions

github-actions Bot commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

🧠 Matt Pocock Skills Reviewer has completed the skills-based review. ✅

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR resolves osgetenvlibrary linter findings by explicitly suppressing os.Getenv usage in library packages where environment reads are the intended boundary (env-to-config adapters), and by consolidating spinner accessibility detection onto the existing IsAccessibleMode() helper.

Changes:

  • Added targeted //nolint:osgetenvlibrary suppressions for env-reading boundary functions/initializers across several packages.
  • Updated pkg/console/spinner.go to use IsAccessibleMode() instead of directly reading ACCESSIBLE.
  • Centralized accessibility-related env checks via IsAccessibleMode() to avoid duplicated logic.
Show a summary per file
File Description
pkg/parser/github.go Suppresses linter on env reads in GitHub host/token boundary helpers.
pkg/logger/logger.go Suppresses linter on init-time env reads used to configure logging/debug behavior.
pkg/github/label_objective_mapping.go Suppresses linter on env override for objective mapping config.
pkg/envutil/envutil.go Suppresses linter in a dedicated env-reading utility helper.
pkg/constants/constants.go Suppresses linter on workflow directory env override boundary.
pkg/console/spinner.go Uses IsAccessibleMode() to determine whether spinners should be enabled.
pkg/console/accessibility.go Suppresses linter for env reads inside the accessibility boundary helper.

Review details

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 7/7 changed files
  • Comments generated: 1
  • Review effort level: Low

Comment thread pkg/console/spinner.go
Comment on lines 101 to +104
// Automatically disabled when not running in a TTY or when ACCESSIBLE env var is set.
func NewSpinner(message string) *SpinnerWrapper {
isTTY := tty.IsStderrTerminal()
isAccessible := os.Getenv("ACCESSIBLE") != ""
isAccessible := IsAccessibleMode()
@github-actions

github-actions Bot commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Design Decision Gate 🏗️ completed the design decision gate check.

No ADR enforcement needed: PR #42163 does not have the 'implementation' label and has only 13 new lines of code in business logic directories (threshold: 100).

@github-actions github-actions Bot mentioned this pull request Jun 29, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review: osgetenvlibrary lint fix

Overall: ✅ Approving. All nolint suppressions are correctly placed at genuine environment-reading boundary functions. The spinner.go refactor to IsAccessibleMode() is a net improvement — it removes duplicated env-var logic and aligns spinner behavior with the canonical accessibility helper.

What's correct:

  • All 13 nolint suppressions are at boundary-layer callsites (env abstraction utilities, purpose-built config readers, init-time readers) — exactly where the linter expects suppression rather than refactoring.
  • The spinner.go behavioral change (now also disabling when TERM=dumb or NO_COLOR is set) is correct: a spinner in a dumb terminal or no-color terminal is undesirable.
  • Token values are never logged in parser/github.go — only the presence of the env var is recorded.

Minor (non-blocking):

  • One inline comment on spinner.go: the function-level and package-level docstrings were not updated to reflect the expanded accessibility conditions now checked via IsAccessibleMode().

🧵 Reviewed using Impeccable skills by Impeccable Skills Reviewer · 30.3 AIC · ⌖ 9.03 AIC · ⊞ 4.9K

Comment thread pkg/console/spinner.go
func NewSpinner(message string) *SpinnerWrapper {
isTTY := tty.IsStderrTerminal()
isAccessible := os.Getenv("ACCESSIBLE") != ""
isAccessible := IsAccessibleMode()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The refactor to IsAccessibleMode() is correct and improves behavior (spinner now also disabled for TERM=dumb and NO_COLOR). However, two nearby docstrings are now stale and should be updated along with this change:

  1. Package doc (spinner.go line 11): Accessibility: Respects ACCESSIBLE environment variable to disable animations — should mention all three env vars that IsAccessibleMode() checks.
  2. Function doc (line 101): when ACCESSIBLE env var is set — should say something like when accessibility mode is active (see IsAccessibleMode) to avoid misleading future readers.

@copilot please address this.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Skills-Based Review 🧠

Applied /zoom-out and /improve-codebase-architecture — clean lint cleanup with one minor doc follow-up.

📋 Key Themes & Highlights

Key Themes

  • Stale documentation: The pkg/console/spinner.go package doc, Accessibility section, and NewSpinner func doc still reference only the ACCESSIBLE env var, but the code now delegates to IsAccessibleMode() which also covers TERM=dumb and NO_COLOR. All three locations need updating (see inline comment).
  • Spinner tests are ACCESSIBLE-only: spinner_test.go's accessibility tests only set ACCESSIBLE=1; worth adding TERM=dumb and NO_COLOR scenarios to match the new delegate semantics, even though IsAccessibleMode() is unit-tested separately.

Positive Highlights

  • Good boundary identification: All 12 nolint suppressions sit at genuine package boundaries (logger init, envutil abstraction, github token/host resolution). None feel like lazy workarounds.
  • Spinner consolidation is a net win: Replacing the duplicated os.Getenv("ACCESSIBLE") with IsAccessibleMode() removes a silent inconsistency — before this change, the spinner was not disabled by TERM=dumb or NO_COLOR even though every other console component respected them.
  • Minimal blast radius: The per-line nolint approach keeps the linter suppression as local as possible.
  • IsAccessibleMode() already has comprehensive test coverage in accessibility_test.go.

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · 55.3 AIC · ⌖ 7.35 AIC · ⊞ 6.6K
Comment /matt to run again

Comment thread pkg/console/spinner.go
func NewSpinner(message string) *SpinnerWrapper {
isTTY := tty.IsStderrTerminal()
isAccessible := os.Getenv("ACCESSIBLE") != ""
isAccessible := IsAccessibleMode()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[/zoom-out] Three doc comments in this file now understate the accessibility conditions after switching from a direct os.Getenv("ACCESSIBLE") check to IsAccessibleMode() — the broader semantics aren't reflected in the docs.

💡 Stale comment locations
  • Line 11 (package doc): "Respects ACCESSIBLE environment variable to disable animations" — should mention all three conditions
  • Lines 34–37 (Accessibility section): describes only the ACCESSIBLE env var with an example; TERM=dumb and NO_COLOR are omitted
  • Line 101 (func doc): "when ACCESSIBLE env var is set" — should reflect the full IsAccessibleMode() semantics

Suggested update for line 101:

// Automatically disabled when not running in a TTY or when IsAccessibleMode() returns true
// (ACCESSIBLE, TERM=dumb, or NO_COLOR env vars).

@copilot please address this.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non-blocking documentation gap in spinner.go

The nolint suppressions are all correctly placed at genuine env-boundary functions. The one real cleanup is in spinner.go, where the spinner behavior has been expanded but the docs haven't caught up — and the gap is in two places, not one.

Details

The existing review thread already flagged the NewSpinner function comment at line 101 (// Automatically disabled when not running in a TTY or when ACCESSIBLE env var is set.).

There are also two more stale doc locations in the package-level block:

  • Line 11: Accessibility: Respects ACCESSIBLE environment variable to disable animations
  • Lines 33–38: The full # Accessibility section, which explicitly documents export ACCESSIBLE=1 as the only way to disable spinner animations.

All three locations need updating to reflect that TERM=dumb and NO_COLOR now also disable spinners via IsAccessibleMode(). The underlying behavior change is intentional and correctly implemented — only the docs lag behind.

No other issues. All other //nolint:osgetenvlibrary additions are correct and appropriately scoped.

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • patchdiff.githubusercontent.com

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "patchdiff.githubusercontent.com"

See Network Configuration for more information.

🔎 Code quality review by PR Code Quality Reviewer · 75.1 AIC · ⌖ 7 AIC · ⊞ 5.2K
Comment /review to run again

Comments that could not be inline-anchored

pkg/console/spinner.go:11

Stale package-level doc — two locations missed: The bullet at line 11 and the # Accessibility block (lines 33–38) still promise only ACCESSIBLE disables spinners. After this change, TERM=dumb and NO_COLOR also disable spinners via IsAccessibleMode().

<details>
<summary>💡 Suggested fixes</summary>

Line 11 (accessibility bullet in package overview):

//   - Accessibility: Disabled when ACCESSIBLE, TERM=dumb, or NO_COLOR is set (see IsAccessibleMode)

Lines 33–38

@github-actions

Copy link
Copy Markdown
Contributor

🤖 PR Triage — §28357644191

Field Value
Category chore
Risk 🟢 Low
Score 37/100 (Impact 10 · Urgency 12 · Quality 15)
Action auto_merge

Adds //nolint:osgetenvlibrary suppressions at justified init-time env-read boundaries (+13/-13, 7 files). CI ✅ passing. All call sites are at the outermost config-read layer. Ready to auto-merge.

Generated by 🔧 PR Triage Agent · 89.9 AIC · ⌖ 12 AIC · ⊞ 5.4K ·

@pelikhan

Copy link
Copy Markdown
Collaborator

@pelikhan pelikhan merged commit 9a25691 into main Jun 29, 2026
84 of 96 checks passed
@pelikhan pelikhan deleted the copilot/lint-monster-refactor-environment-coupling branch June 29, 2026 09:22
Copilot stopped work on behalf of pelikhan due to an error June 29, 2026 09:22
@github-actions

Copy link
Copy Markdown
Contributor

🎉 This pull request is included in a new release.

Release: v0.82.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants