PowerShell / PowerShell/PSScriptAnalyzer
Analyzer for Type Reassignment in `foreach` Loop
まだ誰も着手していません。
- 主要言語
- C#
- スター
- 2.2k
- フォーク
- 414
- 平均マージ
- 13時間 1分
- マージ済み PR(30日)
- 2
説明
Summary of the new feature
Consider the following script:
if ($true) {
[String]$MyVar = "Blah"
}
[int[]]$MyInts = @(1,2,3)
foreach ($MyVar in $MyInts) {
Write-Host "This is my type [$($MyVar.GetType())]"
}
A naïve C# reading of the above PowerShell would assume that the above would print out:
This is my type [int]
This is my type [int]
This is my type [int]
However this is PowerShell and due to Scoping Rules this actually returns:
This is my type [string]
This is my type [string]
This is my type [string]
Proposed technical implementation details (optional)
This has already burned me once in production.
As far as I can tell there is not an existing analyzer to determine this.
It is unclear if it is even feasible to do this reliably.
What is the latest version of PSScriptAnalyzer at the point of writing
PS > Get-Module | Where-Object {$_.Name -eq 'PSScriptAnalyzer' }
ModuleType Version PreRelease Name ExportedCommands
---------- ------- ---------- ---- ----------------
Script 1.19.1 PSScriptAnalyzer {Get-ScriptAnalyzerRule, Invoke-Formatter, Invoke…
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
ソースファイル、テスト、エントリポイントは指定されていません。まず既存のアナライザールールとリンクされている PowerShell のスコープ規則を確認し、その後、foreach ループ内での型の再代入を確実に検出できるかどうかを判断してください。サンプルの動作を網羅するテストを伴う、文書化されたアナライザー診断があれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- csharp, powershell
- 領域
- tooling
- issue の種類
- 機能追加
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 活発さ
- 停滞
- 明瞭さ
- 説明が足りない
- 初心者へのやさしさ
- 25/100