PowerShell / PowerShell/PSScriptAnalyzer
PSAvoidAssignmentToAutomaticVariable Should detect auto-vars as function parameters
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 2.2k
- Forks
- 414
- Avg merge
- 13h 1m
- Merged PRs (30d)
- 2
Description
I did this recently and needed about 30 minutes to find my bug:
function Demo
{
Param (
[string] $input
)
}
You can pass everything to this parameter, no warning, no error and $input is always $null !
See here, too: https://github.com/PowerShell/PSScriptAnalyzer/issues/712 "New Rule Suggestion: AvoidReuseOfAutomaticVariables"
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the PSAvoidAssignmentToAutomaticVariable rule and review the related issue #712. Reproduce the function-parameter example from this issue, then determine how the rule currently detects automatic-variable assignments. Done means the example produces a warning while valid parameters remain unaffected, with coverage for the behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp, powershell
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100