Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions Tests/Rules/UseConsistentIndentation.tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -902,6 +902,37 @@ bar
Invoke-Formatter -ScriptDefinition $def -Settings $settings | Should -Be $def
}

It "Should preserve comment-run indentation in a multiline pipeline using <PipelineIndentation>" -TestCases @(
@{
PipelineIndentation = 'IncreaseIndentationForFirstPipeline'
ExpectedFinalCommandIndentation = ' '
}
@{
PipelineIndentation = 'IncreaseIndentationAfterEveryPipeline'
ExpectedFinalCommandIndentation = ' '
}
) {
param(
[string] $PipelineIndentation,
[string] $ExpectedFinalCommandIndentation
)
$def = @(
'foo |'
' # first comment'
' # nested comment'
' bar |'
"${ExpectedFinalCommandIndentation}baz"
) -join "`n"
$settings.Rules.PSUseConsistentIndentation.PipelineIndentation = $PipelineIndentation

$violations = Invoke-ScriptAnalyzer -ScriptDefinition $def -Settings $settings
$violations | Should -BeNullOrEmpty
$formatted = Invoke-Formatter -ScriptDefinition $def -Settings $settings
$formatted | Should -Be $def
Invoke-Formatter -ScriptDefinition $formatted -Settings $settings |
Should -Be $def
}

It "Should preserve pipeline indentation across a comment line continuation with PipelineIndentation None" {
$def = @'
foo |
Expand Down
Loading