`Invoke-ScriptAnalyzer` parameterset ambiguity
還沒有人認領這個 Issue。
- #2131 來自 @liamjpeters —— 已關閉,未合併
評估
- 難度
- 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
- 分支
- 418
- 平均合併
- 13 小時 1 分鐘
- 30 天內合併 PR
- 2
環境準備
在瀏覽器裡用你自己的 GitHub 帳號啟動這個專案的開發容器。
- 沒有 Dockerfile 或 Docker Compose 檔案
- 有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
PowerShell/PSScriptAnalyzer 的其他 Issue
-
Up-for-Grabs
難度 1/5 1-3 小時 新手友好度 78/100
PowerShell/PSScriptAnalyzer#2213 · 2 則留言 ·
-
難度 4/5 3-5 天 新手友好度 32/100
PowerShell/PSScriptAnalyzer#2222 · 2 則留言 ·
-
難度 3/5 1-2 天 新手友好度 48/100
PowerShell/PSScriptAnalyzer#2220 ·
-
難度 3/5 1-2 天 新手友好度 55/100
PowerShell/PSScriptAnalyzer#2219 ·
-
難度 3/5 1-2 天 新手友好度 72/100
PowerShell/PSScriptAnalyzer#2218 ·
查看 PowerShell/PSScriptAnalyzer 的全部 Issue
相似的 Issue
-
has-image has-readme needs-attention new-tool repo-verified
難度 1/5 1-3 小時 新手友好度 62/100
shanselman/TinyToolTown#844 · 2 則留言 ·
維護者通常 3 天內回覆
-
難度 2/5 1-3 小時 新手友好度 62/100
維護者通常 2 天內回覆
-
難度 2/5 1-3 小時 新手友好度 62/100
PCL-Community/PCL-CE#3658 ·
維護者通常 1 天內回覆
-
Deploy & Patch-issues opprettes ikke: create-pnd-issues.yml har feilet hver uke siden 2025-09-08未關閉
難度 2/5 1-3 小時 新手友好度 62/100
Altinn/altinn-auth#4359 ·
維護者通常 1 天內回覆
-
アプリ: チャット 優先: 中 提案
難度 2/5 1-3 小時 新手友好度 70/100
yksr-melt/Meltype#243 · 1 則留言 ·
維護者通常 1 天內回覆