Rule request: AvoidUsingOutNull
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 45/100
Direzione di ricerca
Individua regole PSScriptAnalyzer comparabili e i relativi test, quindi esamina come vengono rappresentati i nomi delle regole, le gravità, le categorie, le diagnosi e i pattern delle pipeline. Il lavoro è completato quando le pipeline che terminano con Out-Null producono una diagnosi informativa di Style con alternative suggerite, mentre le altre forme di soppressione dell'output rimangono inalterate.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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
- Lingua principale
- C#
- Stelle
- 2.2k
- Fork
- 415
- Merge medio
- 13h 1m
- PR unite (30g)
- 2
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di PowerShell/PSScriptAnalyzer
-
Up-for-Grabs
Difficoltà 1/5 1-3 ore Idoneità per principianti 78/100
PowerShell/PSScriptAnalyzer#2213 · 2 commenti ·
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 72/100
PowerShell/PSScriptAnalyzer#2217 · 1 commento ·
-
PSUseConsistentIndentation double-indents attribute bodies that open a scriptblock (`[Attr({ … })]`) Aperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 70/100
PowerShell/PSScriptAnalyzer#2216 · 2 commenti ·
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 68/100
PowerShell/PSScriptAnalyzer#2211 ·
-
`PSPlaceOpenBrace` and `PSPlaceCloseBrace` leave trailing whitespace when expanding one-line blocks Aperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 70/100
PowerShell/PSScriptAnalyzer#2210 ·
Tutte le issue di PowerShell/PSScriptAnalyzer
Issue simili
-
bug
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 75/100
sillsdev/languageforge-lexbox#2665 ·
-
C: Syntax
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
-
bug documentation frontend
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
azurenoops/spin_agent#975 ·
-
:watch: Not Triaged 11.0 fundamentals/subsvc
Difficoltà 2/5 1-3 ore Idoneità per principianti 92/100
dotnet/AspNetCore.Docs#37699 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
SubtitleEdit/subtitleedit#15108 · 1 commento ·