PowerShell / PowerShell/PSScriptAnalyzer
Rule request: PossibleArgumentWithOperatorConfusion
還沒有人認領這個 Issue。
- 主要語言
- C#
- 星號
- 2.2k
- 分支
- 414
- 平均合併
- 13 小時 1 分鐘
- 30 天內合併 PR
- 2
描述
PowerShell has two parsing modes:
It is not always clear whenever PowerShell is in argument mode, as in:
if (&{ (1,2,3).Where{ $_ -eq 4 } } -isnot [int]) { Throw "The expression should return an integer"
For background information, see: Call operator (&{}) with no results doesn't type compare #24054
Yet from the argument name (and position and the operators) you could make a reasonable assumption that it probably concerns an operator instead.
For a (PowerShell based) rule prototype, see: https://github.com/iRon7/PSRules/blob/main/PossibleArgumentWithOperatorConfusion.psm1
Invoke-ScriptAnalyzer -CustomRulePath $RulePath -ScriptDefinition 'if (&{ (1,2,3).Where{ $_ -eq 4 } } -isnot [int]) { Throw "The expression should return an integer" }' | Select-Object *
Line : 1
Column : 5
Message : Possible argument with operator (-isnot) confusion.
Extent : &{ (1,2,3).Where{ $_ -eq 4 } } -isnot [int]
RuleName : PSPossibleArgumentWithOperatorConfusion
Severity : Warning
ScriptName :
ScriptPath :
RuleSuppressionID :
SuggestedCorrections : {(&{ (1,2,3).Where{ $_ -eq 4} }) -isnot [int]}
IsSuppressed : False
貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
研究方向
從 PossibleArgumentWithOperatorConfusion.psm1 中的 PowerShell 規則原型開始,並檢視連結的 PowerShell 剖析問題以了解背景。將原型的診斷、範圍和建議的修正與現有的 PSScriptAnalyzer 規則進行比較;當所要求的混淆能夠透過適當的警告和修正被偵測到時,即表示完成。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- powershell
- 領域
- tooling
- Issue 類型
- 功能
- 難度
- 4/5
- 預估耗時
- 3-5 天
- 活躍度
- 停滯
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100