`PSPlaceOpenBrace` and `PSPlaceCloseBrace` leave trailing whitespace when expanding one-line blocks
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 70/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Stack tecnológico
- powershell
- Área
- tooling
Línea de trabajo
Comienza reproduciendo el bloque de una sola línea mediante Invoke-Formatter, con PSPlaceOpenBrace y PSPlaceCloseBrace habilitados y IgnoreOneLineBlock establecido en false. Rastrea cómo esas reglas expanden el bloque e inspecciona las pruebas relacionadas del formateador; se considera terminado cuando la salida multilínea esperada no contiene un espacio final después de break sin requerir PSAvoidTrailingWhitespace.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Steps to reproduce
Format a one-line block with IgnoreOneLineBlock = $false:
Invoke-Formatter -ScriptDefinition "if (`$x) { BREAK }" -Settings @{
IncludeRules = @(
'PSPlaceOpenBrace'
'PSPlaceCloseBrace'
'PSUseConsistentIndentation'
'PSUseCorrectCasing'
)
Rules = @{
PSPlaceOpenBrace = @{
Enable = $true
OnSameLine = $true
NewLineAfter = $true
IgnoreOneLineBlock = $false
}
PSPlaceCloseBrace = @{
Enable = $true
NewLineAfter = $true
IgnoreOneLineBlock = $false
}
PSUseConsistentIndentation = @{ Enable = $true }
PSUseCorrectCasing = @{ Enable = $true }
}
}
Expected behavior
Expanding the block should not introduce trailing whitespace:
if ($x) {
break
}
Actual behavior
The output contains a trailing space after break. The ␠ below marks that space:
if ($x) {
break␠
}
The brace corrections replace only the brace tokens. The spaces that separated the one-line content from the braces survive as trailing whitespace after the block is expanded.
PowerShell/PSScriptAnalyzer#1992 and merged PowerShell/PSScriptAnalyzer#1993 are related, but not duplicates. They make PSAvoidTrailingWhitespace available to Invoke-Formatter when explicitly configured. They do not prevent PSPlaceOpenBrace and PSPlaceCloseBrace from introducing trailing whitespace. Callers should not need a separate cleanup rule to remove whitespace created by the formatter itself.
Environment data
Reproduced with:
- PSScriptAnalyzer 1.25.0 on PowerShell 7.5.2
- PSScriptAnalyzer built from
mainat PowerShell/PSScriptAnalyzer@4b0117ca7d2887711c9699f467ba7171f8859156 on PowerShell 7.6.4
- Lenguaje dominante
- C#
- Estrellas
- 2.2k
- Forks
- 415
- Merge medio
- 13 h 1 min
- PR fusionados (30 d)
- 2
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.
Más de PowerShell/PSScriptAnalyzer
-
Up-for-Grabs
Dificultad 1/5 1-3 horas Aptitud para principiantes 78/100
PowerShell/PSScriptAnalyzer#2213 · 2 comentarios ·
-
Dificultad 3/5 1-2 días Aptitud para principiantes 72/100
PowerShell/PSScriptAnalyzer#2217 · 1 comentario ·
-
PSUseConsistentIndentation double-indents attribute bodies that open a scriptblock (`[Attr({ … })]`) Abierto
Dificultad 3/5 1-2 días Aptitud para principiantes 70/100
PowerShell/PSScriptAnalyzer#2216 · 2 comentarios ·
-
Dificultad 3/5 1-2 días Aptitud para principiantes 68/100
PowerShell/PSScriptAnalyzer#2211 ·
-
Dificultad 3/5 1-2 días Aptitud para principiantes 55/100
PowerShell/PSScriptAnalyzer#2209 ·
Todos los issues de PowerShell/PSScriptAnalyzer
Issues similares
-
type/automation type/tech-debt
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
-
t/bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
-
ci-failure-cause test-failure
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
-
area:auth FE mvp P3
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
klasolsson81/jobbliggaren#1788 ·