Skip to content

Wrong indentation for passed scriptblocks in pipe sequence (PSUseConsistentIndentation) #1066

Closed
@felixfbecker

Description

@felixfbecker

Steps to reproduce

Get-ChildItem *.yml |
    Get-Content -Raw |
    ConvertFrom-KubeYaml |
    ForEach-Object {
        switch ($_.Metadata.Name) {
            # ...
        }
    } |
	Update-KubeResource

Expected behavior

Should not cause a rule violation, this is the expected formatting

Actual behavior

Formats to:

Get-ChildItem *.yml |
    Get-Content -Raw |
    ConvertFrom-KubeYaml |
    ForEach-Object {
    switch ($_.Metadata.Name) {
        # ...
    }
} |
    Update-KubeResource

Note how the switch is not indented and the closing brace of the scriptblock is on the wrong level, while the next pipeline element is correct.

Environment data

> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      6.1.0-rc.1
PSEdition                      Core
GitCommitId                    6.1.0-rc.1
OS                             Darwin 17.7.0 Darwin Kernel Version 17.7.0: Thu Jun 21 22:53:14 PDT 2018; root:xnu-4570.71.2~1/RELEASE_X86_64
Platform                       Unix
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0
> (Get-Module -ListAvailable PSScriptAnalyzer).Version | ForEach-Object { $_.ToString() }
1.17.1

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions