From cb454df73f8b2d4d333897a9d16e8837936a9158 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 25 Mar 2026 06:04:27 +0000 Subject: [PATCH] refactor: simplify hasSpecialTriggers to a single boolean expression MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replace 6 if/return-true blocks with a single idiomatic return statement using boolean OR. The behavior is identical — each trigger type check is unchanged — but the control flow is now much easier to read at a glance. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- pkg/workflow/concurrency.go | 43 ++++++------------------------------- 1 file changed, 7 insertions(+), 36 deletions(-) diff --git a/pkg/workflow/concurrency.go b/pkg/workflow/concurrency.go index fae0ae51202..a89a825d002 100644 --- a/pkg/workflow/concurrency.go +++ b/pkg/workflow/concurrency.go @@ -84,43 +84,14 @@ func GenerateJobConcurrencyConfig(workflowData *WorkflowData) string { // workflow-level concurrency handling (issues, PRs, discussions, push, command, // slash_command, or workflow_dispatch-only) func hasSpecialTriggers(workflowData *WorkflowData) bool { - // Check for specific trigger types that have special concurrency handling on := workflowData.On - - // Check for issue-related triggers - if isIssueWorkflow(on) { - return true - } - - // Check for pull request triggers - if isPullRequestWorkflow(on) { - return true - } - - // Check for discussion triggers - if isDiscussionWorkflow(on) { - return true - } - - // Check for push triggers - if isPushWorkflow(on) { - return true - } - - // Check for slash_command triggers (synthetic event that expands to issue_comment + workflow_dispatch) - if isSlashCommandWorkflow(on) { - return true - } - - // workflow_dispatch-only workflows represent explicit user intent, so the - // top-level workflow concurrency group is sufficient – no engine-level group needed - if isWorkflowDispatchOnly(on) { - return true - } - - // If none of the special triggers are detected, return false - // This means other generic triggers (e.g. schedule) will get default concurrency - return false + return isIssueWorkflow(on) || + isPullRequestWorkflow(on) || + isDiscussionWorkflow(on) || + isPushWorkflow(on) || + isSlashCommandWorkflow(on) || + // workflow_dispatch-only represents explicit user intent — top-level concurrency is sufficient + isWorkflowDispatchOnly(on) } // isPullRequestWorkflow checks if a workflow's "on" section contains pull_request triggers