PowerShell / PowerShell/PSScriptAnalyzer
new feature: unusable parameters warning
まだ誰も着手していません。
- 主要言語
- C#
- スター
- 2.2k
- フォーク
- 414
- 平均マージ
- 13時間 1分
- マージ済み PR(30日)
- 2
説明
Problem to be solved
PowerShell (theoretically) supports parameters whose name can consist only from numbers. For example, this is a valid declaration:
function p1([switch]$1) {if ($1) {'Yes'} else {'No'}}
However, it is very hard to call properly this script. This one will not work:
PS /home/iiric> p1
No
PS /home/iiric> p1 -1
No
This is because parser will think -1 is a negative number rather than a parameter name in this instance.
Proper (=hard) way would be to use splatting.
$params = @{ '1' = $true }
PS> p1 @params
Yes
Generally, this is not the only example of such unusable parameters. See response by @vexx32 in PowerShell repo issue.
Summary of the new feature
Create a PSSA rule that warns when such parameters are created, so users are aware ahead of time that they're making parameters that they won't be able to refer to.
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
まず既存の PSScriptAnalyzer ルールと、それらが診断をどのように報告するかを確認し、次にリンク先の PowerShell issue を調べて、使用できないと見なされるケースを確認します。パラメーターを通常の方法で参照できない場合に、数値のみのパラメーター($1 など)も含めて、アナライザーが警告すれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- csharp, powershell
- 領域
- tooling
- issue の種類
- 機能追加
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 35/100