PowerShell / PowerShell/PSScriptAnalyzer

PSUseConsistentWhitespace - Ability to ignore if in a line with multiple pipes

未关闭
#2,162 2 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 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.

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

贡献指南

打开贡献指南

从这里开始

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

调研方向

检查当前的 PSUseConsistentWhitespace 规则以及链接的未解决 issue,以了解空白在各个 pipeline 中是如何应用的。为包含多个 pipe 的行定义确切行为,然后验证所提议的忽略行为能够保留现有的格式检查,同时不影响其他情况。

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

评估

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

把新 issue 发到你的邮箱

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