PowerShell / PowerShell/PSScriptAnalyzer
Invoke-Formatter is not idempotent on `--%` verbatim arguments
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- C#
- Estrellas
- 2.2k
- Forks
- 414
- Merge medio
- 13 h 1 min
- PR fusionados (30 d)
- 2
Descripción
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
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Línea de trabajo
Comienza reproduciendo el ejemplo repetido de Invoke-Formatter con un comando nativo utilizando el token --% stop-parsing. Inspecciona el manejo de CheckPipe de PSUseConsistentWhitespace alrededor del verbatim-argument extent; estará terminado cuando el formateo repetido mantenga estable el espaciado en lugar de insertar otro espacio antes de |.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- powershell
- Área
- tooling
- Tipo de issue
- Error
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Estado de actividad
- Activo
- Claridad
- Bastante claro
- Aptitud para principiantes
- 55/100