Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

`Invoke-ScriptAnalyzer` parameterset ambiguity

オープン
#2,130 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
45/100
issue の種類
リファクタリング
明瞭さ
明確に書かれている
活発さ
停滞
技術スタック
powershell
領域
cli

調査の方向性

Invoke-ScriptAnalyzer のパラメーター宣言から始め、Path と ScriptDefinition のパラメーター セットを、それらの位置指定バインドおよびパイプライン バインドのメタデータを含めて確認します。ScriptDefinition が到達不能な位置指定バインドまたはパイプラインからの値によるバインドを示さなくなり、プロパティ名によるバインドは引き続き利用できるようになったら完了です。issue の例に照らして、結果として得られるコマンドの動作を検証してください。

索引モデルが issue の本文から書いたものです。

説明

Summary

Both the -Path and -ScriptDefinition parameters of Invoke-ScriptAnalyzer are [string] parameters. Both accept ValueFromPipeline and both are declared as Position=0. While they exist in different parameter sets (each with two variants), there is no unique parameter in either set that would allow PowerShell to disambiguate and select the intended parameter set during binding.

As a result, the default parameter set (Path_SuppressedOnly) is always chosen. Any string passed down the pipeline (by value) or as a positional argument is bound to the Path parameter. This means that ScriptDefinition's Position=0 and pipeline (by value) binding declarations are effectively unreachable - any positional or pipeline string will always be bound to Path.

This isn't a bug, but is a design issue: the ScriptDefinition parameter advertises pipeline (by value) and positional binding, but there is no way for users to actually use these features due to parameter set ambiguity.

I propose removing ValueFromPipeline = true and Position = 0 from ScriptDefinition. This isn't a breaking change as they can't currently be used.

ValueFromPipelineByPropertyName is fine - the below works:

[PSCustomObject]@{ScriptDefinition = '$Var = 1'} | Invoke-ScriptAnalyzer

Environment data

> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      7.4.11
PSEdition                      Core
GitCommitId                    7.4.11
OS                             Microsoft Windows 10.0.22631
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

> (Get-Module -ListAvailable PSScriptAnalyzer).Version | ForEach-Object { $_.ToString() }

1.24.0

主要言語
C#
スター
2.2k
フォーク
415
平均マージ
13時間 1分
マージ済み PR(30日)
2

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

PowerShell/PSScriptAnalyzer のほかの issue

PowerShell/PSScriptAnalyzer の issue をすべて見る

似ている issue

C# の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。