PowerShell / PowerShell/PSScriptAnalyzer

Rule request: `Get-Content x | ConvertFrom-Json` should suggest adding `-raw` for `Get-content`

未关闭
#1,951 3 条评论 1 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

Issue - Enhancement Issue - New Rule Up-for-Grabs
主要语言
C#
星标
2.2k
派生
414
平均合并
13 小时 1 分钟
30 天内合并 PR
2

描述

Summary of the new feature

When you call get-content file.json | convertfrom-json, funny things happen when file.json contains a comment at the top of the file.

Multiple places suggest that it's better to use get-content -raw for performance and predictability.

See:

Proposed technical implementation details (optional)

When get-content is piped to convertfrom-*, PSScriptAnalyzer should suggest adding -raw to get-content.

The same could apply to [xml] get-content file.xml.

What is the latest version of PSScriptAnalyzer at the point of writing

1.21

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

未指定源文件或测试。首先检查现有的 PSScriptAnalyzer 规则,了解将 Get-Content 通过管道传给 ConvertFrom-* 的情况,以及链接的 PowerShell issue;确定对 JSON 注释的预期处理方式和可能的 XML 情况。完成的标准是:分析器在适当情况下始终建议使用 -Raw,并且该行为有测试覆盖。

由索引模型根据 Issue 内容生成。

评估

技术栈
csharp, powershell
领域
devtools, tooling
Issue 类型
功能
难度
4/5
预计耗时
3-5 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。