PowerShell / PowerShell/PSScriptAnalyzer
Suggestion for new rule - Ensure that variables used in a function is always declared in the local scope
まだ誰も着手していません。
- 主要言語
- C#
- スター
- 2.2k
- フォーク
- 414
- 平均マージ
- 13時間 1分
- マージ済み PR(30日)
- 2
説明
In order to reduce the number of hard to debug errors, we run our PowerShell scripts with Set-StrictMode -Version Latest. This lets us catch issues where we e.g. have misspelled a variable name (or forgot to assign it before using it) during runtime. But it would be immensely useful to catch these kinds of errors before we run the scripts, e.g. during an automated build.
We have deployment scripts that run for quite a long time (several hours), and silly misspelled variable names or misplaced variable assignments then costs quite a bit of development time. Catching these errors early would be immensely useful.
Example of something that should cause an error:
function Get-Foobar()
{
if ($b + 2 -gt 5)
{
return $b
}
return 5
}
This would be OK:
function Get-Foobar($b)
{
if ($b + 2 -gt 5)
{
return $b
}
return 5
}
As would this:
function Get-Foobar()
{
$b = 123;
if ($b + 2 -gt 5)
{
return $b
}
return 5
}
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
Issue にある 2 つの PowerShell の例から始め、リポジトリに既存の analyzer ルールとテストを調べて、新しいルールをどこに追加すべきか判断します。パラメーター、代入、変数参照をどのように扱うべきかを定義します。未宣言変数の例が報告され、両方の有効な例がパスし、選択した動作に対するカバレッジがあることを完了条件とします。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- powershell
- 領域
- devtools
- issue の種類
- 機能追加
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 30/100