Skip to content

[code-simplifier] simplify submit_pr_review target parsing for consistency#16624

Merged
pelikhan merged 1 commit intomainfrom
code-simplifier/submit-pr-review-cleanup-1dd72dcab236f082
Feb 18, 2026
Merged

[code-simplifier] simplify submit_pr_review target parsing for consistency#16624
pelikhan merged 1 commit intomainfrom
code-simplifier/submit-pr-review-cleanup-1dd72dcab236f082

Conversation

@github-actions
Copy link
Contributor

Summary

Simplifies recently added code in submit_pr_review.go and submit_pr_review.cjs (from PR #16602) for consistency with existing patterns in the codebase.

Files Simplified

  • pkg/workflow/submit_pr_review.go — Remove redundant guard and debug log in target parsing
  • actions/setup/js/submit_pr_review.cjs — Move variable declarations closer to where they're used

Improvements Made

1. Consistent Target Parsing (Go)

The newly added target parsing in submit_pr_review.go included an extra && targetStr != "" guard and a debug log not present in the equivalent create_pr_review_comment.go:

Before:

if target, exists := configMap["target"]; exists {
    if targetStr, ok := target.(string); ok && targetStr != "" {
        config.Target = targetStr
        submitPRReviewLog.Printf("Target: %s", config.Target)
    }
}

After (matching create_pr_review_comment.go):

if target, exists := configMap["target"]; exists {
    if targetStr, ok := target.(string); ok {
        config.Target = targetStr
    }
}

The != "" check is redundant — setting Target to "" is equivalent to not setting it (empty string is the zero value and the validation layer treats it as the default "triggering" behavior). The extra log line was inconsistent with how other parsers handle target.

2. Narrowed Variable Scope (JavaScript)

repo and repoParts were declared before the resolveTarget() call but only used inside the else if (targetResult.number) branch. Moving them inside that branch narrows their scope, making the code easier to follow.

Based On

PR #16602 — Fix submit_pull_request_review when not in pull_request trigger

Testing

  • ✅ JS syntax validated (node --check)
  • ✅ Existing tests cover target parsing: TestSubmitPullRequestReviewConfig passes "target": "42" and verifies correct parsing
  • ✅ No functional changes — behavior is identical

References: §22153377350

AI generated by Code Simplifier

  • expires on Feb 19, 2026, 7:06 PM UTC

- Remove redundant '&& targetStr != ""' check (setting Target to empty
  string is equivalent to not setting it; consistent with create_pr_review_comment.go)
- Remove per-target debug log (not present in other similar parsers)
- Move repo/repoParts declarations inside the else-if branch where they
  are used, narrowing scope and improving readability

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@pelikhan pelikhan marked this pull request as ready for review February 18, 2026 19:25
Copilot AI review requested due to automatic review settings February 18, 2026 19:25
@pelikhan pelikhan merged commit e269471 into main Feb 18, 2026
4 checks passed
@pelikhan pelikhan deleted the code-simplifier/submit-pr-review-cleanup-1dd72dcab236f082 branch February 18, 2026 19:25
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 recently added code from PR #16602 to align with established patterns in the codebase. The changes remove redundant code and improve variable scoping without altering functionality.

Changes:

  • Simplified target parsing in Go to match the pattern used in create_pr_review_comment.go
  • Narrowed variable scope in JavaScript for better code clarity

Reviewed changes

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

File Description
pkg/workflow/submit_pr_review.go Removed redundant empty string check and debug log from target parsing to match create_pr_review_comment.go pattern
actions/setup/js/submit_pr_review.cjs Moved repo and repoParts variable declarations inside the else if (targetResult.number) block where they're actually used

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

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