-
Notifications
You must be signed in to change notification settings - Fork 1.2k
fix(powershell-generator): remove trailing comma from last entry #485
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(powershell-generator): remove trailing comma from last entry #485
Conversation
📝 WalkthroughWalkthroughThis PR fixes a PowerShell parser error by introducing a private helper method to strip trailing commas from array literals in generated completion scripts. The fix ensures syntactically valid PowerShell arrays without trailing commas that previously caused "Missing expression after ','" exceptions. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
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. Comment |
Review CompleteYour review story is ready! Comment !reviewfast on this PR to re-generate the story. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
test/core/completions/generators/powershell-generator.test.ts (1)
447-473: Good regression test; consider extending coverage.The test validates the fix for the reported issue with proper cross-platform line ending handling. However, the subcommand
gethas no flags, so thegenerateArgumentCompletioncode path (line 159 in the generator) isn't directly exercised.🔧 Optional: Add flags to the subcommand for fuller coverage
subcommands: [ { name: 'get', description: 'Get a config value', - flags: [], + flags: [ + { + name: 'verbose', + description: 'Verbose output', + }, + ], }, ],
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
src/core/completions/generators/powershell-generator.tstest/core/completions/generators/powershell-generator.test.ts
🧰 Additional context used
🧬 Code graph analysis (1)
test/core/completions/generators/powershell-generator.test.ts (2)
src/core/completions/types.ts (1)
CommandDefinition(36-72)scripts/postinstall.js (2)
script(81-81)generator(80-80)
🔇 Additional comments (6)
src/core/completions/generators/powershell-generator.ts (5)
11-14: Clean implementation of the helper method.The guard for empty arrays and the regex pattern correctly handle the trailing comma removal. The in-place mutation is appropriate here since all call sites own their arrays.
25-29: Correct placement for top-level commands.The helper is called after all command entries are added, properly stripping the trailing comma from the last entry before joining.
87-98: Correct handling for parent command flags.The helper is correctly placed after the flag entries loop, and the
cmd.flags.length > 0guard ensures entries exist.
110-114: Correct handling for subcommand entries.Properly strips trailing comma from the last subcommand entry within the guarded block.
149-160: Correct handling for flags in argument completion.This covers the code path for commands without subcommands, ensuring their flag arrays also have trailing commas stripped.
test/core/completions/generators/powershell-generator.test.ts (1)
1-3: LGTM.Standard import formatting.
TabishB
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nobShinjo Thank you for this fix 🫶
Summary
@()arrays when generating completionsTesting
pnpm exec vitest run test/core/completions/generators/powershell-generator.test.tsRelated
Summary by CodeRabbit
Bug Fixes
Tests
✏️ Tip: You can customize this high-level summary in your review settings.