PowerShell / PowerShell/PSScriptAnalyzer
Invoke-Formatter is not idempotent on `--%` verbatim arguments
まだ誰も着手していません。
- 主要言語
- C#
- スター
- 2.2k
- フォーク
- 414
- 平均マージ
- 13時間 1分
- マージ済み PR(30日)
- 2
説明
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
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
まず、--% stop-parsing トークンを使用するネイティブ コマンドで、Invoke-Formatter の繰り返し実行例を再現します。verbatim-argument extent 周辺の PSUseConsistentWhitespace の CheckPipe 処理を調査します。繰り返しフォーマットしても空白が安定し、| の前にさらに空白が挿入されなければ完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- powershell
- 領域
- tooling
- issue の種類
- バグ
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 活発さ
- 活発
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 55/100