Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions pkg/console/accessibility.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import "os"
// - Simplify interactive elements
// - Use plain text instead of fancy formatting
func IsAccessibleMode() bool {
return os.Getenv("ACCESSIBLE") != "" ||
os.Getenv("TERM") == "dumb" ||
os.Getenv("NO_COLOR") != ""
return os.Getenv("ACCESSIBLE") != "" || //nolint:osgetenvlibrary
os.Getenv("TERM") == "dumb" || //nolint:osgetenvlibrary
os.Getenv("NO_COLOR") != "" //nolint:osgetenvlibrary
}
2 changes: 1 addition & 1 deletion pkg/console/spinner.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ type SpinnerWrapper struct {
// 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()
Comment on lines 101 to +104

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.

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.

enabled := isTTY && !isAccessible
spinnerLog.Printf("Creating spinner: message=%q, tty=%t, accessible=%t, enabled=%t", message, isTTY, isAccessible, enabled)
s := &SpinnerWrapper{enabled: enabled}
Expand Down
2 changes: 1 addition & 1 deletion pkg/constants/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,7 @@ const UsrLocalPrefix = "/usr/local"
// Always uses forward slashes, which are required for git/GitHub paths.
// GH_AW_WORKFLOWS_DIR overrides the default; any OS-specific separators are normalized.
func GetWorkflowDir() string {
if dir := os.Getenv("GH_AW_WORKFLOWS_DIR"); dir != "" {
if dir := os.Getenv("GH_AW_WORKFLOWS_DIR"); dir != "" { //nolint:osgetenvlibrary
return filepath.ToSlash(dir)
}
return WorkflowsDir
Expand Down
2 changes: 1 addition & 1 deletion pkg/envutil/envutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func GetIntFromEnv(envVar string, defaultValue, minValue, maxValue int, debugLog
}
}

envValue := os.Getenv(envVar)
envValue := os.Getenv(envVar) //nolint:osgetenvlibrary
if envValue == "" {
return defaultValue
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/github/label_objective_mapping.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ func LoadObjectiveMappingFromConfig() *ObjectiveMapping {
labelObjectiveMappingLog.Print("Loading objective mapping configuration")

// Try loading from OBJECTIVE_MAPPING_JSON env var
if mappingJSON := os.Getenv("OBJECTIVE_MAPPING_JSON"); mappingJSON != "" {
if mappingJSON := os.Getenv("OBJECTIVE_MAPPING_JSON"); mappingJSON != "" { //nolint:osgetenvlibrary
labelObjectiveMappingLog.Print("Attempting to load from OBJECTIVE_MAPPING_JSON env var")
var om ObjectiveMapping
if err := json.Unmarshal([]byte(mappingJSON), &om); err == nil {
Expand Down
6 changes: 3 additions & 3 deletions pkg/logger/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ var (
debugEnv = initDebugEnv()

// DEBUG_COLORS environment variable to control color output.
debugColors = os.Getenv("DEBUG_COLORS") != "0"
debugColors = os.Getenv("DEBUG_COLORS") != "0" //nolint:osgetenvlibrary

// Color palette for namespace coloring, using adaptive styles.
colorPalette = []lipgloss.Style{
Expand All @@ -51,10 +51,10 @@ var (
// If DEBUG is set, it takes precedence. Otherwise, if ACTIONS_RUNNER_DEBUG=true,
// all loggers are enabled (equivalent to DEBUG=*).
func initDebugEnv() string {
if d := os.Getenv("DEBUG"); d != "" {
if d := os.Getenv("DEBUG"); d != "" { //nolint:osgetenvlibrary
return d
}
if os.Getenv("ACTIONS_RUNNER_DEBUG") == "true" {
if os.Getenv("ACTIONS_RUNNER_DEBUG") == "true" { //nolint:osgetenvlibrary
return "*"
}
return ""
Expand Down
6 changes: 3 additions & 3 deletions pkg/parser/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func GetGitHubHost() string {
envVars := []string{"GITHUB_SERVER_URL", "GITHUB_ENTERPRISE_HOST", "GITHUB_HOST", "GH_HOST"}

for _, envVar := range envVars {
if value := os.Getenv(envVar); value != "" {
if value := os.Getenv(envVar); value != "" { //nolint:osgetenvlibrary
githubLog.Printf("Resolved GitHub host from %s: %s", envVar, value)
return stringutil.NormalizeGitHubHostURL(value)
}
Expand Down Expand Up @@ -62,11 +62,11 @@ func GetGitHubToken() (string, error) {
githubLog.Print("Getting GitHub token")

// First try environment variable
if token := os.Getenv("GITHUB_TOKEN"); token != "" {
if token := os.Getenv("GITHUB_TOKEN"); token != "" { //nolint:osgetenvlibrary
githubLog.Print("Found GITHUB_TOKEN environment variable")
return token, nil
}
if token := os.Getenv("GH_TOKEN"); token != "" {
if token := os.Getenv("GH_TOKEN"); token != "" { //nolint:osgetenvlibrary
githubLog.Print("Found GH_TOKEN environment variable")
return token, nil
}
Expand Down
Loading