PowerShell / PowerShell/PSScriptAnalyzer

Rule request: PossibleArgumentWithOperatorConfusion

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

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

Issue - New Rule Issue-Enhancement Up-for-Grabs
主要言語
C#
スター
2.2k
フォーク
414
平均マージ
13時間 1分
マージ済み PR(30日)
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

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

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

はじめの一歩

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

調査の方向性

PossibleArgumentWithOperatorConfusion.psm1 にある PowerShell ルールのプロトタイプから始め、背景を把握するためにリンクされている PowerShell のパースに関する issue を確認してください。プロトタイプの診断、範囲、提案されている修正を既存の PSScriptAnalyzer ルールと比較してください。要求された混乱が適切な警告と修正によって検出されれば完了です。

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

評価

技術スタック
powershell
領域
tooling
issue の種類
機能追加
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
35/100

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

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