PowerShell / PowerShell/PSScriptAnalyzer
Private parameters are reported as unused
オープン
まだ誰も着手していません。
Issue - Enhancement
Up-for-Grabs
- 主要言語
- C#
- スター
- 2.2k
- フォーク
- 414
- 平均マージ
- 13時間 1分
- マージ済み PR(30日)
- 2
説明
Before submitting a bug report:
- Make sure you are able to repro it on the latest released version
- Perform a quick search for existing issues to check if this bug has already been reported
Steps to reproduce
Run the analyzer against this script.
Param (
[String] $private:var1
)
function Test-Second
{
# $var1 is not accessible because it was private to the script.
Write-Information -InformationAction "continue" "From script: $var1"
# $var2 is not private to the calling function so we can access it.
Write-Information -InformationAction "continue" "From caller: $var2"
}
function Test-NotGlobal
{
Param (
[String] $var2
)
$a = $var1 + " " + $var2
Write-Information -InformationAction "continue" "Concatenation: $a"
Test-Second
}
Test-NotGlobal $var1
Expected behavior
Expect no errors because $private:var1 and the use in the last line of $var1 are the same variable and $var1 is private to the script, as required.
Actual behavior
PS C:\Users\pauldsmith> Invoke-ScriptAnalyzer c:\temp\gvar.ps1
RuleName Severity ScriptName Line Message
-------- -------- ---------- ---- -------
PSReviewUnusedParameter Warning gvar.ps1 2 The parameter 'private:var1' has been declared but not
used.
PS C:\Users\pauldsmith>
If an unexpected error was thrown then please report the full error details using e.g. $error[0] | Select-Object *
Environment data
> $PSVersionTable
Name Value
---- -----
PSVersion 5.1.22621.963
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.22621.963
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
> (Get-Module -ListAvailable PSScriptAnalyzer).Version | ForEach-Object { $_.ToString() }
1.21.0
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
まず、PowerShell の再現コードに対して Invoke-ScriptAnalyzer を実行し、PSReviewUnusedParameter ルールの実装とカバレッジを調べます。private パラメーターとその最後の使用箇所が同じ変数として認識されることを確認します。完了の条件は、再現コードで未使用パラメーターの警告が生成されないことです。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- powershell
- 領域
- tooling
- issue の種類
- バグ
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 45/100