Skip to content

[code-simplifier] Simplify null check idiom and update stale comment in add_comment.cjs#35118

Merged
pelikhan merged 1 commit into
mainfrom
code-simplifier/2026-05-27-a302a9eac6c869c0
May 27, 2026
Merged

[code-simplifier] Simplify null check idiom and update stale comment in add_comment.cjs#35118
pelikhan merged 1 commit into
mainfrom
code-simplifier/2026-05-27-a302a9eac6c869c0

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot commented May 27, 2026

Summary

Simplifies a null-check idiom and refreshes a stale inline comment in add_comment.cjs.

Changes

actions/setup/js/add_comment.cjs (modified — low impact, non-breaking)

  • Null-check simplification: Replaced a strict === undefined (or equivalent) guard on error?.status with the == null idiom, which correctly covers both null and undefined in a single expression.
  • Comment update: Revised the associated inline comment to accurately reflect the updated check and remove stale wording.

Impact

Area Impact
Behaviour None — semantically equivalent for all practical inputs
Breaking changes None
Tests required No new tests needed; existing coverage is sufficient

Commit

Hash Message
d699fcc simplify: use == null idiom and update stale comment in add_comment.cjs

Generated by PR Description Updater for issue #35118 · sonnet46 673.9K ·

Replace explicit '=== undefined || === null' with idiomatic '== null'
for the isLockedByKnownMessageWithoutStatus check. In JavaScript, == null
correctly matches both undefined and null without matching 0 or other
falsy values.

Also update stale comment 'For non-404 errors, fail as before' to
'For all other errors, propagate the failure' now that locked errors
are also handled separately above.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@pelikhan pelikhan marked this pull request as ready for review May 27, 2026 05:03
Copilot AI review requested due to automatic review settings May 27, 2026 05:03
@pelikhan pelikhan merged commit b57cf93 into main May 27, 2026
10 checks passed
@pelikhan pelikhan deleted the code-simplifier/2026-05-27-a302a9eac6c869c0 branch May 27, 2026 05:03
@github-actions
Copy link
Copy Markdown
Contributor Author

github-actions Bot commented May 27, 2026

Design Decision Gate 🏗️ completed the design decision gate check.

No ADR enforcement needed: PR #35118 does not have the 'implementation' label and has 0 new lines of code in default business logic directories (well below the 100-line threshold).

@github-actions
Copy link
Copy Markdown
Contributor Author

github-actions Bot commented May 27, 2026

PR Code Quality Reviewer completed the code quality review.

No action needed: PR #35118 is already merged. Both changes are correct — error?.status == null is semantically equivalent to the explicit triple-equals checks, and the comment update accurately reflects current control flow.

@github-actions
Copy link
Copy Markdown
Contributor Author

github-actions Bot commented May 27, 2026

🧠 Matt Pocock Skills Reviewer has completed the skills-based review. ✅

@github-actions
Copy link
Copy Markdown
Contributor Author

github-actions Bot commented May 27, 2026

🧪 Test Quality Sentinel completed test quality analysis.

No test files were added or modified in this PR. The only changed file is actions/setup/js/add_comment.cjs (2 additions, 2 deletions). Test Quality Sentinel skipped.

Copy link
Copy Markdown
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 error classification logic in the add_comment safe-output handler by using an idiomatic null/undefined check, and updates an adjacent comment to better reflect the current control flow introduced in #35064.

Changes:

  • Replace an explicit undefined/null disjunction with error?.status == null for the “missing status” lock-detection path.
  • Update a stale inline comment describing how non-404 errors are handled.
Show a summary per file
File Description
actions/setup/js/add_comment.cjs Simplifies the “missing status” lock detection check and updates an error-handling comment for accuracy.

Copilot's findings

Tip

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

  • Files reviewed: 1/1 changed files
  • Comments generated: 1

const isHttp423Locked = error?.status === 423;
const isHttp403WithLockedMessage = error?.status === 403 && normalizedErrorMessage.includes("locked");
const isLockedByKnownMessageWithoutStatus = (error?.status === undefined || error?.status === null) && hasKnownLockPhrase;
const isLockedByKnownMessageWithoutStatus = error?.status == null && hasKnownLockPhrase;
@github-actions github-actions Bot mentioned this pull request May 27, 2026
Copy link
Copy Markdown
Contributor Author

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Skills-Based Review 🧠

Applied /zoom-out — changes are correct and well-reasoned. Approving.

📋 Analysis

Semantic Equivalence ✅

error?.status == null is identical in behaviour to (error?.status === undefined || error?.status === null) — the abstract equality check with null matches exactly null and undefined, and nothing else. The simplification is safe.

Comment Update ✅

The updated comment // For all other errors, propagate the failure is more accurate: by this point in the control flow, 404, 423, and 403-locked cases have all been handled, so "non-404" was indeed stale and misleading.

Positive Highlights

  • ✅ Idiomatic JavaScript — == null is the canonical null/undefined guard
  • ✅ Comment accurately reflects the current control flow
  • ✅ Zero functional change — a pure readability win

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · sonnet46 861.3K

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