Skip to content

fix: format and lint#78

Merged
chawyehsu merged 5 commits into
ScoopInstaller:mainfrom
chawyehsu:push-rlmopsytppnv
May 8, 2026
Merged

fix: format and lint#78
chawyehsu merged 5 commits into
ScoopInstaller:mainfrom
chawyehsu:push-rlmopsytppnv

Conversation

@chawyehsu
Copy link
Copy Markdown
Member

@chawyehsu chawyehsu commented May 7, 2026

Relate to #77

Summary by CodeRabbit

  • New Features

    • Updated extraction help content shown to users for extraction/decompression errors.
    • Final PR comment and checklist formatting improved (small layout change and more consistent checklist entries).
  • Bug Fixes

    • Issue handling now responds only to opened and labeled events, reducing spurious processing.
  • Chores

    • Internal refactor and logging standardization for more reliable operation and maintainability.

Signed-off-by: Chawye Hsu <su+git@chawyehsu.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 7, 2026

Review Change Stack

Warning

Rate limit exceeded

@chawyehsu has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 43 minutes and 51 seconds before requesting another review.

To continue reviewing without waiting, purchase usage credits in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 609055ad-3ee2-47c3-a832-104edc4d2c29

📥 Commits

Reviewing files that changed from the base of the PR and between d43fede and 0bb35ec.

📒 Files selected for processing (10)
  • .pslintrules.psd1
  • action.ps1
  • src/Action/Issue.psm1
  • src/Action/Issue/Extraction.psm1
  • src/Action/PR.psm1
  • src/Action/Scheduled.psm1
  • src/ActionWrapper.psm1
  • src/Github.psm1
  • src/Helpers.psm1
  • src/Scoop.psm1

Walkthrough

Rename event variables to $GITHUB_*, add ShouldProcess guards and fix parameter attributes on several cmdlets, refactor PR flow (repo context + final message changes), rename/clean extraction help helper, adjust helper exports, and standardize ConvertTo-Json casing and event logging.

Changes

Event, Cmdlets, Helpers, Actions, and Logging

Layer / File(s) Summary
Event variables
src/Variables.psm1, action.ps1
Parse and export $GITHUB_EVENT, $GITHUB_EVENT_RAW, $GITHUB_EVENT_TYPE; action logs use $GITHUB_EVENT_RAW.
Github cmdlets
src/Github.psm1
Remove ValueFromPipeline from mandatory params; add CmdletBinding(SupportsShouldProcess) and ShouldProcess gating to New-Issue and Remove-Label.
Helpers
src/Helpers.psm1
Add SupportsShouldProcess to in-memory helpers, remove/relocate ConvertTo-CheckList implementation, update exports, and remove pipeline input from Expand-Property.Object.
PR action flow
src/Action/PR.psm1
Switch PR handling to $GITHUB_EVENT/*, add Set-RepositoryContext for git operations, use `ConvertTo-CheckList
Issue & extraction
src/Action/Issue.psm1, src/Action/Issue/Extraction.psm1
Initialize-Issue reads from $GITHUB_EVENT.issue.*, gates on `opened
Logging casing
src/ActionWrapper.psm1, action.ps1
Change ConvertTo-Json -compress-Compress in logs and update full-event log to use $GITHUB_EVENT_RAW.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Suggested reviewers

  • deevus

Poem

🐰 A tiny hop through code tonight,
GITHUB names made clear and bright,
Guards that ask "ShouldProcess?" first,
Checklists piped, not buried in dust.
Logs now crisp — the rabbit's delight!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Title check ❓ Inconclusive The title 'fix: format and lint' is vague and generic, using non-descriptive terms that don't convey meaningful information about the specific changes (renaming variables, removing pipeline attributes, adjusting function verbs). Consider a more specific title like 'refactor: rename EVENT variables to GITHUB_EVENT and improve API compatibility' that reflects the actual changes made.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

chawyehsu added 3 commits May 7, 2026 23:42
Signed-off-by: Chawye Hsu <su+git@chawyehsu.com>
Signed-off-by: Chawye Hsu <su+git@chawyehsu.com>
Signed-off-by: Chawye Hsu <su+git@chawyehsu.com>
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/Helpers.psm1 (1)

48-54: ⚡ Quick win

Consider suppressing the lint rule instead of guarding pure helpers with ShouldProcess.

New-Array, New-DetailsCommentString, and New-CheckListItem are pure, in-memory factory helpers — they don't mutate any external state. Wiring them through SupportsShouldProcess only to silence PSUseShouldProcessForStateChangingFunctions introduces a real footgun: under -WhatIf (or a non-default $WhatIfPreference), each helper returns $null, which breaks callers like $responses = New-Array; Add-IntoArray $responses … in src/Action/PR.psm1 and src/Action/Issue/Extraction.psm1.

Either suppress the rule on these specific functions, or pick a non-state-changing verb. Example for New-Array:

♻️ Suggested alternative
 function New-Array {
     <#
     .SYNOPSIS
         Create new Array list. More suitable for usage as it provides better operations.
     #>
-    [CmdletBinding(SupportsShouldProcess)]
-    param()
-
-    if ($PSCmdlet.ShouldProcess('In-memory', 'Create New Array')) {
-        return New-Object System.Collections.ArrayList
-    }
+    [Diagnostics.CodeAnalysis.SuppressMessageAttribute(
+        'PSUseShouldProcessForStateChangingFunctions', '',
+        Justification = 'In-memory factory; no external state is changed.')]
+    param()
+
+    return New-Object System.Collections.ArrayList
 }

The same idea applies to New-DetailsCommentString and New-CheckListItem.

Also applies to: 153-203

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/Helpers.psm1` around lines 48 - 54, The helper functions New-Array,
New-DetailsCommentString, and New-CheckListItem are pure in-memory factories and
must not be gated by SupportsShouldProcess/ShouldProcess (which makes them
return $null under -WhatIf); remove the CmdletBinding/ShouldProcess guard from
these functions so they always return their value, and instead suppress the
PSUseShouldProcessForStateChangingFunctions rule for each helper (add the
appropriate PSScriptAnalyzer suppression comment for
PSUseShouldProcessForStateChangingFunctions above each function) or rename to a
non-state-changing verb if you prefer; ensure callers like Add-IntoArray
continue to receive a non-null ArrayList from New-Array.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/Github.psm1`:
- Around line 199-204: The DELETE request URL in the loop uses the wrong
variable ($label) which stringifies the whole $Label array; update the
interpolated path in the Invoke-GithubRequest call inside the foreach ($lab in
$Label) loop to use $lab instead of $label so each individual label is deleted;
ensure this change is applied where Add-IntoArray calls Invoke-GithubRequest
(the delete branch) and that the surrounding variables ($issueLabels, $lab,
Add-IntoArray, Invoke-GithubRequest) remain unchanged.

---

Nitpick comments:
In `@src/Helpers.psm1`:
- Around line 48-54: The helper functions New-Array, New-DetailsCommentString,
and New-CheckListItem are pure in-memory factories and must not be gated by
SupportsShouldProcess/ShouldProcess (which makes them return $null under
-WhatIf); remove the CmdletBinding/ShouldProcess guard from these functions so
they always return their value, and instead suppress the
PSUseShouldProcessForStateChangingFunctions rule for each helper (add the
appropriate PSScriptAnalyzer suppression comment for
PSUseShouldProcessForStateChangingFunctions above each function) or rename to a
non-state-changing verb if you prefer; ensure callers like Add-IntoArray
continue to receive a non-null ArrayList from New-Array.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 8d5264b2-9556-4951-9d7a-034328378f03

📥 Commits

Reviewing files that changed from the base of the PR and between 2589f08 and d43fede.

📒 Files selected for processing (8)
  • action.ps1
  • src/Action/Issue.psm1
  • src/Action/Issue/Extraction.psm1
  • src/Action/PR.psm1
  • src/ActionWrapper.psm1
  • src/Github.psm1
  • src/Helpers.psm1
  • src/Variables.psm1
✅ Files skipped from review due to trivial changes (2)
  • src/ActionWrapper.psm1
  • action.ps1
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/Action/Issue/Extraction.psm1

Comment thread src/Github.psm1
Comment on lines +199 to 204
foreach ($lab in $Label) {
if ($issueLabels -contains $lab) {
# https://developer.github.com/v3/issues/labels/#list-labels-on-an-issue
Add-IntoArray $responses (Invoke-GithubRequest -Query "repos/$REPOSITORY/issues/$ID/labels/$label" -Method Delete)
}
}
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot May 7, 2026

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Confirm the typo is present in the file under review and check if any caller
# currently passes a multi-element label array to Remove-Label.
rg -nP -C3 '\b(Remove-Label)\b'
rg -nP -C2 '"\s*repos/\$REPOSITORY/issues/\$ID/labels/\$label\s*"'

Repository: ScoopInstaller/GithubActions

Length of output: 3753


🌐 Web query:

PowerShell variable name case sensitivity rules

💡 Result:

PowerShell variable names are case-insensitive. This means $myVar, $MyVar, and $MYVAR all refer to the same variable.[1][2] PowerShell is designed to be case-insensitive wherever possible while preserving the case used in the original reference.[1] Official Microsoft documentation explicitly lists variable names as case-insensitive on all systems.[1] Variable names can include alphanumeric characters, underscores, spaces, and special characters (with curly braces for those), but best practices recommend alphanumeric and underscores only.[2] This behavior holds across scopes, as scope modifiers and variable resolution follow the same case-insensitive rules.[1][3]

Citations:


Fix critical bug: Variable name should be $lab not $label in DELETE request URL (line 202).

PowerShell variable names are case-insensitive, so $label in the interpolated URL resolves to the parameter $Label (an array). When an array is stringified in a URL, it uses the default $OFS separator (space), producing a malformed request. For example, Remove-Label -Label 'verify','hash-fix-needed' becomes:

DELETE repos/<owner>/<repo>/issues/<id>/labels/verify hash-fix-needed

This prevents actual label deletion. The loop iterates over individual labels with variable $lab, so that is the correct reference.

Proposed fix
         foreach ($lab in $Label) {
             if ($issueLabels -contains $lab) {
                 # https://developer.github.com/v3/issues/labels/#list-labels-on-an-issue
-                Add-IntoArray $responses (Invoke-GithubRequest -Query "repos/$REPOSITORY/issues/$ID/labels/$label" -Method Delete)
+                Add-IntoArray $responses (Invoke-GithubRequest -Query "repos/$REPOSITORY/issues/$ID/labels/$lab" -Method Delete)
             }
         }

At least one caller (src/Action/PR.psm1:114) passes a variable that may contain multiple labels, making this a functional defect.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
foreach ($lab in $Label) {
if ($issueLabels -contains $lab) {
# https://developer.github.com/v3/issues/labels/#list-labels-on-an-issue
Add-IntoArray $responses (Invoke-GithubRequest -Query "repos/$REPOSITORY/issues/$ID/labels/$label" -Method Delete)
}
}
foreach ($lab in $Label) {
if ($issueLabels -contains $lab) {
# https://developer.github.com/v3/issues/labels/#list-labels-on-an-issue
Add-IntoArray $responses (Invoke-GithubRequest -Query "repos/$REPOSITORY/issues/$ID/labels/$lab" -Method Delete)
}
}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/Github.psm1` around lines 199 - 204, The DELETE request URL in the loop
uses the wrong variable ($label) which stringifies the whole $Label array;
update the interpolated path in the Invoke-GithubRequest call inside the foreach
($lab in $Label) loop to use $lab instead of $label so each individual label is
deleted; ensure this change is applied where Add-IntoArray calls
Invoke-GithubRequest (the delete branch) and that the surrounding variables
($issueLabels, $lab, Add-IntoArray, Invoke-GithubRequest) remain unchanged.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This pull request only concerns format and lint. I'll open another PR to resolve this and other pre-existing bugs.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

@chawyehsu, understood — thanks for the clarification! That's a reasonable scope boundary for this PR.

Would you like me to open a GitHub issue to track the $label$lab variable bug (and any other pre-existing bugs you have in mind) so nothing gets lost before the follow-up PR?

Signed-off-by: Chawye Hsu <su+git@chawyehsu.com>
@chawyehsu chawyehsu merged commit dfaf4c0 into ScoopInstaller:main May 8, 2026
2 checks passed
@chawyehsu chawyehsu mentioned this pull request May 8, 2026
@chawyehsu chawyehsu deleted the push-rlmopsytppnv branch May 8, 2026 10:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant