PowerShell / PowerShell/PSScriptAnalyzer
Write-Host should be closed within the scope it was created in, unless it is a Async command type
まだ誰も着手していません。
- 主要言語
- C#
- スター
- 2.2k
- フォーク
- 414
- 平均マージ
- 13時間 1分
- マージ済み PR(30日)
- 2
説明
Summary of the new feature
Some times people don't properly close their Write-progress calls with a -Completed which can cause unexpected output, or "leftover" progress bars from commands that completed, but never closed their progress bars
Proposed technical implementation details (optional)
Write-Progress automatically stops showing open progress bars when execution is complete, but this means that if you are making an interface that does not properly close their Write-Progress progress bars with a Write-Progress -Activity $ActivityName -Completed then it stays open while other code is running, until execution stops.
It seems like in vanilla shell console, powershell can recognize that it is "done" (I'm guessing.... maybe something like the scope that created the Write-Progress is stopped? )
But if you do this in other environments, like ISE, then the Progress bars don't go away unless properly closed with a -Completed
Additionally there is the case that people who are running with something like -PercentComplete 100 but never closing.
A recommendation to close Write-Progress'es with a -Completed would effectively stop this problem
Possibly make sure each write-progress -Activity has a matching one with -Completed ? Not sure if there is a way to detect if it's closed in the same scope or if that might cause more problems
A potential problem for that would be things like People start it in the begin { } block write over time in the progress { } block, but not closing in the end { } block?
What is the latest version of PSScriptAnalyzer at the point of writing
As far as I can tell, it does nothing for this currently
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
まず、PowerShell コマンドに対する既存の analyzer ルールとテストを見つけます。この issue では Write-Progress と対応する -Completed 呼び出しが挙げられていますが、ファイルやエントリーポイントは示されていません。スコープ境界と begin/process/end ブロックがどのように動作すべきかを明確にし、その後、実装前に通常のコマンド型と async コマンド型をカバーするテストを定義します。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- csharp, powershell
- 領域
- tooling
- issue の種類
- 機能追加
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 活発さ
- 停滞
- 明瞭さ
- 説明が足りない
- 初心者へのやさしさ
- 20/100