PowerShell / PowerShell/PSScriptAnalyzer

PSAvoidUsingCmdletAliases triggers on GherkinStep

未關閉
#896 3 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

Area - Rules Issue - Enhancement Up-for-Grabs
主要語言
C#
星號
2.2k
分支
414
平均合併
13 小時 1 分鐘
30 天內合併 PR
2

描述

Gherkin (including in Pester) has a few aliases which you are meant to use when creating steps.

Alias           And -> GherkinStep                                 4.2.0      Pester
Alias           But -> GherkinStep                                 4.2.0      Pester
Alias           Given -> GherkinStep                               4.2.0      Pester
Alias           Then -> GherkinStep                                4.2.0      Pester
Alias           When -> GherkinStep                                4.2.0      Pester

These are valid uses of the alias and shouldn't trigger analyzer warnings.

Steps to reproduce

Create a Gherkin (Pester) step file like Blah.Steps.ps1

Given "something" {
}

Then Invoke-ScriptAnalyzer Blah.Steps.ps1

Expected behavior

No issues.

Actual behavior

RuleName                            Severity     ScriptName Line  Message
--------                            --------     ---------- ----  -------
PSAvoidUsingCmdletAliases           Warning      Blah.Steps 1     'Given' is an alias of 'GherkinStep'. Alias can introduce
                                                 .ps1             possible problems and make scripts hard to maintain. Please
                                                                  consider changing alias to its full content.

Environment data

Name                           Value
----                           -----
PSVersion                      5.1.14393.1944
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.14393.1944
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

1.16.1

貢獻指南

開啟貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

研究方向

透過執行 Invoke-ScriptAnalyzer,使用 Blah.Steps.ps1 範例重現警告,重點關注 PSAvoidUsingCmdletAliases 和 GherkinStep 別名。完成的標準是:將 Given、And、But、When 和 Then 作為 Pester Gherkin 步驟使用時不會產生任何分析器問題,而一般別名仍然受該規則涵蓋。

由索引模型根據 Issue 內容生成。

評估

技術堆疊
csharp, powershell
領域
tooling
Issue 類型
缺陷
難度
3/5
預估耗時
1-2 天
活躍度
停滯
描述清晰度
描述清楚
新手友好度
35/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。