PowerShell / PowerShell/PSScriptAnalyzer
Invoke-Formatter is not idempotent on `--%` verbatim arguments
Personne n'a encore pris cette issue.
- Langage dominant
- C#
- Étoiles
- 2.2k
- Forks
- 414
- Merge moyen
- 13 h 1 min
- PR mergées (30 j)
- 2
Description
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
Guide de contribution
Ouvrir le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Piste de recherche
Commencez par reproduire l’exemple répété de Invoke-Formatter avec une commande native utilisant le token --% stop-parsing. Examinez la gestion de CheckPipe de PSUseConsistentWhitespace autour du verbatim-argument extent ; c’est terminé lorsque le formatage répété laisse l’espacement stable au lieu d’insérer un espace supplémentaire avant |.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- powershell
- Domaine
- tooling
- Type d'issue
- Bug
- Difficulté
- 3/5
- Temps estimé
- 1-2 jours
- Activité
- Active
- Clarté
- Plutôt claire
- Accessibilité débutants
- 55/100