PowerShell / PowerShell/PSScriptAnalyzer

Invoke-Formatter is not idempotent on `--%` verbatim arguments

Abierto
#2,209 0 comentarios 0 reacciones 0 asignados Ver en GitHub

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 main at PowerShell/PSScriptAnalyzer@4b0117ca7d2887711c9699f467ba7171f8859156 on PowerShell 7.6.4

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. 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

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.