PowerShell / PowerShell/PSScriptAnalyzer
PSAvoidUsingCmdletAliases triggers on GherkinStep
未关闭
还没有人认领这个 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
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 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