-
Notifications
You must be signed in to change notification settings - Fork 399
Fix edge case of PSUseConsistentIndentation for non-default value (IncreaseIndentationForFirstPipeline/IncreaseIndentationAfterEveryPipeline) #1423
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
dd3cfd3
f63e335
c252651
6021b3e
ab454fe
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -225,6 +225,48 @@ baz | |
Test-CorrectionExtentFromContent @params | ||
} | ||
|
||
It "Should indent pipelines correctly using <PipelineIndentation> option" -TestCases @( | ||
@{ | ||
PipelineIndentation = 'IncreaseIndentationForFirstPipeline' | ||
ExpectCorrection = $true | ||
}, | ||
@{ | ||
PipelineIndentation = 'IncreaseIndentationAfterEveryPipeline' | ||
ExpectCorrection = $true | ||
}, | ||
@{ | ||
PipelineIndentation = 'NoIndentation' | ||
ExpectCorrection = $false | ||
} | ||
@{ | ||
PipelineIndentation = 'None' | ||
ExpectCorrection = $false | ||
} | ||
) { | ||
Param([string] $PipelineIndentation, [bool] $ExpectCorrection) | ||
$def = @' | ||
foo | bar | | ||
baz | ||
'@ | ||
$settings.Rules.PSUseConsistentIndentation.PipelineIndentation = $PipelineIndentation | ||
$violations = Invoke-ScriptAnalyzer -ScriptDefinition $def -Settings $settings | ||
if ($ExpectCorrection) { | ||
$violations.Count | Should -Be 1 | ||
$params = @{ | ||
RawContent = $def | ||
DiagnosticRecord = $violations[0] | ||
CorrectionsCount = 1 | ||
ViolationText = "baz" | ||
CorrectionText = (New-Object -TypeName String -ArgumentList $indentationUnit, ($indentationSize * 1)) + 'baz' | ||
|
||
} | ||
Test-CorrectionExtentFromContent @params | ||
} | ||
else | ||
{ | ||
$violations | Should -BeNullOrEmpty | ||
} | ||
} | ||
|
||
It 'Should preserve script when using PipelineIndentation None' -TestCases @( | ||
@{ IdempotentScriptDefinition = @' | ||
foo | | ||
|
Uh oh!
There was an error while loading. Please reload this page.