Skip to content
Merged
Show file tree
Hide file tree
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
3 changes: 2 additions & 1 deletion Rules/UseConsistentWhitespace.cs
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,8 @@ private IEnumerable<DiagnosticRecord> FindParameterViolations(Ast ast)
testAst => testAst is CommandAst, true);
foreach (CommandAst commandAst in commandAsts)
{
List<Ast> commandParameterAstElements = commandAst.FindAll(testAst => true, searchNestedScriptBlocks: false).ToList();
List<Ast> commandParameterAstElements = commandAst.FindAll(
testAst => testAst.Parent == commandAst, searchNestedScriptBlocks: false).ToList();
for (int i = 0; i < commandParameterAstElements.Count - 1; i++)
{
IScriptExtent leftExtent = commandParameterAstElements[i].Extent;
Expand Down
4 changes: 2 additions & 2 deletions Tests/Rules/UseConsistentWhitespace.tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -474,11 +474,11 @@ bar -h i `
}

It "Should fix script to always have 1 space between parameters except when using colon syntax but not by default" {
$def = 'foo -bar $baz -ParameterName: $ParameterValue'
$def = 'foo -bar $baz -ParameterName: $ParameterValue "$PSScriptRoot\module.psd1"'
Invoke-Formatter -ScriptDefinition $def |
Should -BeExactly $def -Because 'CheckParameter configuration is not turned on by default (yet) as the setting is new'
Invoke-Formatter -ScriptDefinition $def -Settings $settings |
Should -BeExactly 'foo -bar $baz -ParameterName: $ParameterValue'
Should -BeExactly 'foo -bar $baz -ParameterName: $ParameterValue "$PSScriptRoot\module.psd1"'
}

It "Should fix script when newlines are involved" {
Expand Down