PowerShell / PowerShell/PSScriptAnalyzer
AvoidAssignmentToAutomaticVariable doesn't distinguish between normal and DSC scripts
还没有人认领这个 Issue。
- 主要语言
- C#
- 星标
- 2.2k
- 派生
- 414
- 平均合并
- 13 小时 1 分钟
- 30 天内合并 PR
- 2
描述
The AvoidAssignmentToAutomaticVariable rule doesn't distinguish between a normal script and a DSC script, meaning DSC specific auto-variables like $allNodes will cause complaints when the rule runs. I don't know if this is even something that could have logic applied to it in an effort to suppress, given there isn't necessarily an easy way to discern context of DSC vs Non-DSC scripts
Steps to reproduce
Create a standard powershell script ps1 file and enter the following. If in VS Code PSScriptAnalyzer automatically runs against it.
$allNodes = "Put anything here"
Expected behavior
Rule does not complain about usage of $allNodes as script is not used in DSC.
Actual behavior
The Variable 'allNodes' is an automatic variable that is built into PowerShell, assigning to it might have undesired side effects. If assignment is not by design, please use a different name.
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
从 AvoidAssignmentToAutomaticVariable 规则开始,使用包含对 $allNodes 赋值的标准 PowerShell .ps1 重现该问题。确定该规则是否能够区分 DSC 脚本和普通脚本,然后验证普通脚本的情况下不再报告此变量,同时不改变预期的 DSC 行为。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- powershell
- 领域
- tooling
- Issue 类型
- 缺陷
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100