Skip to content

[code-simplifier] Code Simplification - 2026-03-15: domains command and safe-outputs token logic#21104

Merged
pelikhan merged 1 commit intomainfrom
code-simplifier/2026-03-15-simplify-domains-and-safe-outputs-6c6b1ef0ca427bd4
Mar 15, 2026
Merged

[code-simplifier] Code Simplification - 2026-03-15: domains command and safe-outputs token logic#21104
pelikhan merged 1 commit intomainfrom
code-simplifier/2026-03-15-simplify-domains-and-safe-outputs-6c6b1ef0ca427bd4

Conversation

@github-actions
Copy link
Contributor

This PR simplifies recently modified code from PRs #21086 and #21083 to improve clarity and remove unnecessary intermediaries while preserving all functionality.

Files Simplified

  • pkg/cli/domains_command.go — removed strconv import and redundant temp variables
  • pkg/workflow/compiler_safe_outputs_steps.go — simplified token fallback logic

Improvements Made

1. Eliminated unnecessary strconv.Itoa conversions

strconv.Itoa was used to format integers as strings only to pass them as %s to fmt.Fprintf. Using %d directly is cleaner, removes two intermediate variables, and drops the strconv import entirely.

// Before
allowedCount := strconv.Itoa(len(allowedDomains))
blockedCount := strconv.Itoa(len(blockedDomains))
fmt.Fprintf(os.Stderr, "\n%s allowed, %s blocked\n", allowedCount, blockedCount)

// After
fmt.Fprintf(os.Stderr, "\n%d allowed, %d blocked\n", len(allowedDomains), len(blockedDomains))

2. Removed redundant count temporary variable

The count variable was only used twice immediately after assignment — directly accessing len(summaries) is clearer.

3. Simplified token fallback in computeEffectiveProjectToken

The && safeOutputsToken != "" guard is redundant: assigning an empty string to an already-empty variable is a no-op. Removing it and renaming configTokentoken makes the intent clearer.

// Before
configToken := perConfigToken
if configToken == "" && safeOutputsToken != "" {
    configToken = safeOutputsToken
}
return getEffectiveProjectGitHubToken(configToken)

// After
token := perConfigToken
if token == "" {
    token = safeOutputsToken
}
return getEffectiveProjectGitHubToken(token)

Changes Based On

Recent changes from:

Testing

  • ✅ All pkg/cli tests pass (go test ./pkg/cli/...)
  • ✅ Build succeeds (make build)
  • ✅ Formatted (make fmt)
  • ✅ No functional changes — behavior is identical

References: §23116938699

Generated by Code Simplifier ·

  • expires on Mar 16, 2026, 6:59 PM UTC

…outputs

- Replace strconv.Itoa + %s with %d format verb in domains_command.go
- Remove intermediate count variable in RunListDomains
- Remove redundant && safeOutputsToken != "" condition in computeEffectiveProjectToken
- Drop unused strconv import

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@pelikhan pelikhan marked this pull request as ready for review March 15, 2026 19:05
Copilot AI review requested due to automatic review settings March 15, 2026 19:05
@pelikhan pelikhan merged commit 6fe6a29 into main Mar 15, 2026
1 check passed
@pelikhan pelikhan deleted the code-simplifier/2026-03-15-simplify-domains-and-safe-outputs-6c6b1ef0ca427bd4 branch March 15, 2026 19:06
Copy link
Contributor

Copilot AI left a comment

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 simplifies two recently introduced code paths to remove unnecessary temporary variables and redundant checks while preserving behavior.

Changes:

  • Simplifies gh aw domains console output by removing strconv usage and redundant len(...) intermediates.
  • Simplifies computeEffectiveProjectToken fallback logic by removing a redundant empty-string guard and clarifying variable naming.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
pkg/workflow/compiler_safe_outputs_steps.go Simplifies project token fallback logic without changing precedence/behavior.
pkg/cli/domains_command.go Simplifies workflow/domain count formatting and removes now-unneeded strconv import.

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

You can also share your feedback on Copilot code review. Take the survey.

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.

2 participants