PowerShell / PowerShell/PSScriptAnalyzer

Normalisation of new lines after pipes in expressions with 2 or more pipes

Open
#1,755 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Area - Formatter Issue - Enhancement
Dominant language
C#
Stars
2.2k
Forks
414
Avg merge
13h 1m
Merged PRs (30d)
2

Description

Summary of the new feature

Consider the following

$List | Where-Object {
} |
    ForEach-Object {
    }

This is a formatted piece of PowerShell with the notable feature of using both no new line after the pipe and new line after the pipe. The new rule would normalise the presence of a new line after a pipe across the input data.
The rule would have the option to enforce new lines or enforce no new lines after a pipe.

For example,

$List | Where-Object {
} |
    ForEach-Object {
    }

would become

$List | Where-Object {
} | ForEach-Object {
}

If there only exists one pipe, then removing a Newline pending its line length could also be within the scope of the feature.

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

PS > (Get-Module -ListAvailable PSScriptAnalyzer).Version | ForEach-Object { $_.ToString() }
1.19.1

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue names no files, tests, or entry points; begin by locating the formatter entry point responsible for pipe-newline handling. Use the supplied mixed-newline examples to define expected normalization and clarify whether the rule applies to single pipes and line-length limits. Done means the selected enforcement option produces consistent output and its behavior is covered by tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
powershell
Domain
tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.