PowerShell / PowerShell/PSScriptAnalyzer

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

オープン
#2,162 コメント 2 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

主要言語
C#
スター
2.2k
フォーク
414
平均マージ
13時間 1分
マージ済み PR(30日)
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. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

現在の PSUseConsistentWhitespace ルールとリンクされた未解決の issue を確認し、パイプライン全体で空白がどのように適用されているかを理解します。複数のパイプを含む行について正確な動作を定義し、提案された無視動作によって既存のフォーマットチェックが維持され、他のケースに影響しないことを検証します。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
csharp, powershell
領域
devtools, tooling
issue の種類
機能追加
難易度
5/5
見積もり時間
1週間以上
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
35/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。