PowerShell / PowerShell/PSScriptAnalyzer
PSPlaceCloseBrace can't handle empty lines
Nessuno ha ancora preso questa issue.
- Lingua principale
- C#
- Stelle
- 2.2k
- Fork
- 414
- Merge medio
- 13h 1m
- PR unite (30g)
- 2
Descrizione
Basically, it gets fixed if I have:
}
else {
But it doesn't get fixed if I have:
}
else {
And I would really like it to be able to handle:
}
# An explanation of the next code block
else {
And format it like:
} else {
# An explanation of the next code block
Steps to reproduce
Invoke-Formatter {
if (Test-Path ReadMe.md) {
Show-Markdown ReadMe.md
}
elseif (Test-Path ReadMe*) {
Get-Item ReadMe* | Select-Object -First 1 | Get-Content
}
} -Settings @{
Rules = @{
PSPlaceCloseBrace = @{
Enable = $true
NoEmptylineBefore = $true
NewLineAfter = $false
}
}
}
Expected behavior
It should output
if (Test-Path ReadMe.md) {
Show-Markdown ReadMe.md
} elseif (Test-Path ReadMe*) {
Get-Item ReadMe* | Select-Object -First 1 | Get-Content
}
Actual behavior
if (Test-Path ReadMe.md) {
Show-Markdown ReadMe.md
}
elseif (Test-Path ReadMe*) {
Get-Item ReadMe* | Select-Object -First 1 | Get-Content
}
Environment data
> $PSVersionTable
$PSVersionTable
Name Value
---- -----
PSVersion 7.1.0
PSEdition Core
GitCommitId 7.1.0
OS Microsoft Windows 10.0.19041
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
> (Get-Module -ListAvailable PSScriptAnalyzer).Version | ForEach-Object { $_.ToString() }
1.19.1
1.18.1
1.18.0
1.17.1
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.
Direzione di ricerca
Riproduci il comportamento con Invoke-Formatter e le impostazioni di PSPlaceCloseBrace mostrate nell’issue, confrontando i casi con righe vuote e commenti. Traccia il percorso del formatter di PSScriptAnalyzer per questa regola; il lavoro è completato quando una riga vuota o un commento interposto non impedisce più di unire la graffa di chiusura e else come previsto.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- csharp, powershell
- Ambito
- tooling
- Tipo di issue
- Bug
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 48/100