Conversation
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>
|
Hey One thing that would lift this to If you'd like a hand, here's a prompt to address this:
|
There was a problem hiding this comment.
Pull request overview
Refactors hasSpecialTriggers to use a single idiomatic boolean OR expression while preserving the same trigger checks used to decide whether to skip default job-level concurrency.
Changes:
- Replaced a sequential
if { return true }chain with a singlereturn a || b || ...expression inhasSpecialTriggers.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Simplifies
hasSpecialTriggersinpkg/workflow/concurrency.go, recently added in #22825.Files Simplified
pkg/workflow/concurrency.go— Replaced 6 sequentialif/return trueblocks with a single idiomaticreturnusing boolean ORImprovement
The original implementation used a pattern common in early drafts — checking each condition individually and returning
truefrom each — but Go idiom favors a direct boolean expression for this kind of "is any of these true?" query:Before (36 lines including comments):
After (7 lines):
Changes Based On
Recent change from #22825 which introduced the
hasBotSelfCancelRiskand related concurrency helpers.Testing
TestHasSpecialTriggerssubtests pass (all 9 cases)TestHasBotSelfCancelRisksubtests passTestBotActorIsolationInConcurrencyKeyssubtests passTestGenerateConcurrencyConfigWithBotIsolationsubtests passmake build)Review Focus
Please verify the boolean expression covers exactly the same trigger types as the original if-chain.
Note
🔒 Integrity filter blocked 1 item
The following item were blocked because they don't meet the GitHub integrity level.
pull_request_read: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".To allow these resources, lower
min-integrityin your GitHub frontmatter: