Skip to content

[code-simplifier] refactor: simplify default case in buildSafeOutputJobsEnvVars#20568

Merged
pelikhan merged 1 commit intomainfrom
simplify/notify-comment-default-case-fa6d5ba0eb63783f
Mar 11, 2026
Merged

[code-simplifier] refactor: simplify default case in buildSafeOutputJobsEnvVars#20568
pelikhan merged 1 commit intomainfrom
simplify/notify-comment-default-case-fa6d5ba0eb63783f

Conversation

@github-actions
Copy link
Contributor

Simplification of recently merged code from PR #20548.

Files Simplified

  • pkg/workflow/notify_comment.go — Reduced dual-continue pattern in buildSafeOutputJobsEnvVars to a single continue by inverting the condition

Improvement Made

The default case previously had two separate continue statements:

// Before
default:
    if systemSafeOutputJobNames[jobName] {
        // Skip known system jobs — they are not custom safe output types
        continue
    }
    // Custom safe-output job: include in the mapping with an empty URL key so the
    // handler manager can silently skip messages of this type.
    jobOutputMapping[jobName] = ""
    continue

Simplified to a single continue at the end by inverting the condition:

// After
default:
    if !systemSafeOutputJobNames[jobName] {
        // Custom safe-output job: include in the mapping with an empty URL key so the
        // handler manager can silently skip messages of this type.
        jobOutputMapping[jobName] = ""
    }
    continue

This makes the control flow clearer: all paths in the default case lead to a single continue, with the conditional assignment being the only variable part. No behavioral change.

Changes Based On

Recent change from #20548 — "Fix safe_outputs: skip PR review comments outside PR context, register custom safe job types"

Testing

  • ✅ All TestBuildSafeOutputJobsEnvVars tests pass
  • ✅ Build succeeds (make build)
  • ✅ Code formatted (make fmt)
  • ✅ No functional changes — behavior is identical

References: §22969347549

Generated by Code Simplifier ·

  • expires on Mar 12, 2026, 7:04 PM UTC

Invert the systemSafeOutputJobNames condition to reduce the number of
continue statements in the default case from two to one. This makes the
control flow clearer: all paths in the default case lead to a single
continue at the end, with the conditional assignment being the only
variable part.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@pelikhan pelikhan merged commit 5cf1a80 into main Mar 11, 2026
@pelikhan pelikhan deleted the simplify/notify-comment-default-case-fa6d5ba0eb63783f branch March 11, 2026 19:25
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.

1 participant