PowerShell / PowerShell/PSScriptAnalyzer
Rule request: AvoidUsingOutNull
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 2.2k
- Forks
- 414
- Avg merge
- 13h 1m
- Merged PRs (30d)
- 2
Description
Summary of the new feature
I want PSScriptAnalyzer to flag uses of Out-Null for output suppression so that I can maintain consistent code style and potentially gain minor performance improvements.
Currently, many PowerShell scripts use | Out-Null to suppress command output, but there are alternative approaches like [void], > $null, or assignment to $null that are stylistically preferred by many developers. While the performance difference is minimal, having a consistent approach to output suppression improves code readability and maintainability.
Proposed technical implementation details (optional)
- Rule Name:
AvoidUsingOutNull - Severity:
Information(since this is primarily a style preference) - Category:
Style - Detection: Flag any pipeline that ends with
| Out-Null - Suggested alternatives:
[void](command)command > $null$null = command
- Example violation:
Get-Process | Out-Null - Example fix:
[void](Get-Process)orGet-Process > $null
The rule should provide informational messages suggesting these alternatives while acknowledging that this is primarily a stylistic choice rather than a critical performance issue.
What is the latest version of PSScriptAnalyzer at the point of writing
1.24.0
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
Locate comparable PSScriptAnalyzer rules and their tests, then inspect how rule names, severities, categories, diagnostics, and pipeline patterns are represented. Done means pipelines ending in Out-Null produce an informational Style diagnostic with suggested alternatives, while other output-suppression forms remain unaffected.
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
- 45/100