style: drop named parameters from single-argument calls in test scaffolding#36
Conversation
|
Warning Review limit reached
Your plan includes 1 review of capacity. Refill in 10 minutes and 54 seconds. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more review capacity refills, a review can be triggered using the 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 trial, open-source, and free plans. In all cases, review capacity refills continuously over time. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (7)
📝 WalkthroughWalkthroughPowerShell template test scaffolding is updated to enforce a consistent named-parameter style: single-argument function calls now use positional arguments, while multi-argument calls retain named parameters. The changelog documents this rule, test infrastructure files (discovery, manifest validation, helper modules) apply the change, and unit test templates implement it in setup and test cases. ChangesNamed Parameter Style Enforcement
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Possibly related issues
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🧪 Generate unit tests (beta)
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 |
There was a problem hiding this comment.
Pull request overview
This PR updates the template’s Pester test scaffolding to follow a scoped style rule: use positional binding for single-argument calls, and reserve named parameters for calls with two or more value arguments (or where naming is semantically required, e.g., -LiteralPath).
Changes:
- Dropped named parameters from single-value-argument calls across test scaffolding and unit test templates (e.g.,
Get-Module $name,Test-Path $path,Import-PowerShellDataFile $path). - Kept named parameters where they materially aid correctness or clarity (e.g., multi-argument calls like
Join-Path -Path ... -ChildPath ..., andTest-Path -LiteralPath ...). - Documented the scaffolding style change in
CHANGELOG.md.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| tests/Unit/Public/Get-{{Prefix}}Example.tests.ps1 | Switches single-argument calls (module import/build plumbing + function invocation) to positional. |
| tests/Unit/Private/Invoke-{{Prefix}}Helper.tests.ps1 | Switches single-argument calls (module import/build plumbing + helper invocation) to positional. |
| tests/MetaFixers.psm1 | Drops -Path / single-arg parameter names in internal helper implementations while preserving behavior. |
| tests/Meta.tests.ps1 | Updates MetaFixers import and helper invocations to positional single-argument calls. |
| tests/Manifest.tests.ps1 | Updates module root/version resolution and imports to positional single-argument calls. |
| tests/Help.tests.ps1 | Updates discovery/import plumbing and helper calls to positional single-argument calls; keeps multi-arg calls named. |
| CHANGELOG.md | Records the test scaffolding style adjustment under Unreleased changes. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…olding Apply the scoped named-parameter rule to the template's test scaffolding: name parameters only on calls that pass two or more arguments; single-argument calls stay positional. Reverts over-naming such as `Test-Path -Path $path`, `Get-Module -Name $name`, and `Get-Help -Name $command` to positional across the Help/Manifest/Meta tests, MetaFixers, and the Unit test templates. A trailing switch counts as an argument, so `Split-Path -Path $x -Parent`, `Get-Content -Path $x -Raw`, `Get-ChildItem -Path $x -Recurse`, and `Sort-Object -Property 'Name' -Unique` keep their names, as do genuinely multi-value calls (`Join-Path`, `Get-Content -Path -Encoding -Raw`, `Get-Command -Name -CommandType`) and `Test-Path -LiteralPath` (whose positional slot binds to -Path). Common parameters such as -ErrorAction and -Verbose do not count toward the threshold. Canonical-source fix for the over-naming that propagated into the consumer test-scaffolding PRs; pairs with the rule scoping in tablackburn/ai-agent-instruction-modules#25. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
b0b007b to
20c9af0
Compare
Summary
Test-Path -Path $path,Get-Module -Name $name) back to positional acrosstests/Help.tests.ps1,tests/Manifest.tests.ps1,tests/Meta.tests.ps1,tests/MetaFixers.psm1, and thetests/Unit/templates.This is the canonical-source fix for the over-naming that propagated into the consumer "align test scaffolding" PRs (
tablackburn/PlexAutomationToolkit#55,tablackburn/ReScenePS#18); those will re-sync from this once it lands. Pairs with the rule scoping intablackburn/ai-agent-instruction-modules#25.What stays named (intentionally)
Join-Path -Path … -ChildPath …,Get-Content -Path … -Encoding … -Raw,Get-Command -Name … -CommandType ….Test-Path -LiteralPath (…)— position 0 binds to-Path(which does wildcard expansion), so dropping the name would change behavior..EXAMPLEcalls inMetaFixers.psm1— left named for teaching clarity.Test plan
HEAD(pre-existing warnings unchanged).Breaking changes
None — behavior-preserving; positional binding confirmed for every reverted call.
Summary by CodeRabbit
Style
Documentation