PowerShell / PowerShell/PSScriptAnalyzer
Invoke-Formatter is not idempotent on `--%` verbatim arguments
Nessuno ha ancora preso questa issue.
- Lingua principale
- C#
- Stelle
- 2.2k
- Fork
- 414
- Merge medio
- 13h 1m
- PR unite (30g)
- 2
Descrizione
Steps to reproduce
Run the formatter repeatedly on a native command that uses the stop-parsing token:
$formatted = $null
1..3 | ForEach-Object {
$formatted = Invoke-Formatter ($formatted ?? 'cmd --% raw | text & stuff')
$formatted
}
Expected behavior
Formatting already formatted output should be a no-op. Spacing adjacent to the verbatim argument should either be left untouched or normalized once to a stable result.
Actual behavior
One additional space is inserted before | on every run:
cmd --% raw | text & stuff
cmd --% raw | text & stuff
cmd --% raw | text & stuff
The output grows without bound in a format-on-save loop.
The verbatim-argument token owns the text up to the pipe. PSUseConsistentWhitespace with CheckPipe sees a zero-width gap before | and inserts a space inside the verbatim argument's extent on each formatting pass.
Environment data
Reproduced with:
- PSScriptAnalyzer 1.25.0 on PowerShell 7.5.2
- PSScriptAnalyzer 1.25.0 on PowerShell 7.6.3
- PSScriptAnalyzer built from
mainat PowerShell/PSScriptAnalyzer@4b0117ca7d2887711c9699f467ba7171f8859156 on PowerShell 7.6.4
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
Inizia riproducendo l'esempio ripetuto di Invoke-Formatter con un comando nativo usando il token --% stop-parsing. Esamina la gestione di CheckPipe di PSUseConsistentWhitespace intorno al verbatim-argument extent; è completato quando la formattazione ripetuta mantiene stabile la spaziatura invece di inserire un altro spazio prima di |.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- powershell
- Ambito
- tooling
- Tipo di issue
- Bug
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Stato di attività
- Attiva
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 55/100