PowerShell / PowerShell/PSScriptAnalyzer
Settings param cannot be set to $_ inside of a foreach-object loop
還沒有人認領這個 Issue。
- 主要語言
- C#
- 星號
- 2.2k
- 分支
- 415
- 平均合併
- 13 小時 1 分鐘
- 30 天內合併 PR
- 2
描述
When the value of the -Settings parameter is set to $_ inside of a foreach-object loop, PSScriptAnalyzer is unable to find the settings file.
Steps to reproduce:
Create a file that violates a rule that is only checked if a particular setting is triggered.
IE:
if ($true)
{
Write-Output 'Something'
}
This code will throw errors if -Settings is set to CodeFormattingStroustrup but not if -Settings it is omitted.
The following command returns warnings.
invoke-scriptanalyzer -path C:\files\ax.ps1 -Settings 'CodeFormattingStroustrup'
But this one does not.
'CodeFormattingStroustrup' | % { invoke-scriptanalyzer -path C:\files\ax.ps1 -Settings $_ }
Using -Verbose on the non-working example shows that PSScriptAnalyzer cannot find a settings file.
This occurs on version 1.15.0 of PSScriptAnalyzer.
Screenshot

貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
研究方向
從 Invoke-ScriptAnalyzer 入口點開始,使用 -Verbose 重現直接的 -Settings 值與 foreach-object 形式之間的差異。追蹤兩次呼叫中設定值的解析方式;完成標準是,透過管線傳入的 $_ 形式能夠定位 CodeFormattingStroustrup,並回報與直接命令相同的警告。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- powershell
- 領域
- tooling
- Issue 類型
- 缺陷
- 難度
- 3/5
- 預估耗時
- 1-2 天
- 活躍度
- 停滯
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100