PSScriptAnalyzer icon indicating copy to clipboard operation
PSScriptAnalyzer copied to clipboard

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

Open iadcode opened this issue 3 years ago • 0 comments

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

iadcode avatar Dec 16 '21 02:12 iadcode