PowerShell / PowerShell/PSScriptAnalyzer
PSUseConsistentWhitespace - Ability to ignore if in a line with multiple pipes
还没有人认领这个 Issue。
- 主要语言
- C#
- 星标
- 2.2k
- 派生
- 414
- 平均合并
- 13 小时 1 分钟
- 30 天内合并 PR
- 2
描述
Summary of the new feature
The various PSUseConsistentWhitespace rules have various issues that might never be solved:
My biggest issue is that I don't want it to touch one liners or multiliners like this:
(
(
Invoke-RestMethod -Method 'Get' -Uri 'https://api.github.com/repos/chocolatey/choco/releases'
) | Where-Object -Property 'prerelease' -NE $true
).'tag_name' | Sort-Object -Property @{'Expression' = {[System.Version]$_}} -Descending | Select-Object -First 1
Which becomes this:
(
(
Invoke-RestMethod -Method 'Get' -Uri 'https://api.github.com/repos/chocolatey/choco/releases'
) | Where-Object -Property 'prerelease' -NE $true
).'tag_name' | Sort-Object -Property @{'Expression' = { [System.Version]$_ } } -Descending | Select-Object -First 1
If I could tell PSScriptAnalyzer to ignore cases like that I'd be happy.
Current impact
This makes it so that I don't use the code formatting presets, and instead define all the rules manually and disable most of the PSUseConsistentWhitespace rules.
Side note: Would be great with the ability to override built-in presets, so you don't have to specify all the rules.
- 2017-03-07 "Add ability to inherit settings": https://github.com/PowerShell/PSScriptAnalyzer/issues/791
- 2024-12-01 "Code formatting preset - Add ability to override settings set by preset": https://github.com/PowerShell/vscode-powershell/issues/5109
Proposed technical implementation details (optional)
Don't know. Some ideas:
- Ability to ignore if more than one pipe `| is found on the same line?
What is the latest version of PSScriptAnalyzer at the point of writing
v1.24.0
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
检查当前的 PSUseConsistentWhitespace 规则以及链接的未解决 issue,以了解空白在各个 pipeline 中是如何应用的。为包含多个 pipe 的行定义确切行为,然后验证所提议的忽略行为能够保留现有的格式检查,同时不影响其他情况。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- csharp, powershell
- 领域
- devtools, tooling
- Issue 类型
- 功能
- 难度
- 5/5
- 预计耗时
- 一周以上
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100