PowerShell / PowerShell/PSScriptAnalyzer
No 'Variable Referenced Before Assignment' Rule?
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 2.2k
- Forks
- 414
- Avg merge
- 13h 1m
- Merged PRs (30d)
- 2
Description
From what I can tell, there's no linting rule to check if a variable is null or unassigned when it's being referenced. This would be super helpful to avoid nullref errors when running a script or module. I know there's a "variable assigned but not referenced/used" rule, but that's kind of the opposite of what I'm looking for.
I know this functionality exists in pylint for python, but I sorely miss this when working with PowerShell.
Does this exist? If so, how does one enable it?
Apologies if there is already an issue for this somewhere. I couldn't find one.
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 reviewing PSScriptAnalyzer's existing rule for variables that are assigned but not referenced, then check whether a corresponding unassigned-variable rule already exists and how rules are enabled. Define done as either documenting the existing rule or specifying and implementing a rule that reports variables referenced before assignment, with coverage for the reported null-reference case.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- powershell
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100