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
4 changes: 2 additions & 2 deletions Rules/UseConsistentWhitespace.cs
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ private IEnumerable<DiagnosticRecord> FindInnerBraceViolations(TokenOperations t
foreach (var lCurly in tokenOperations.GetTokenNodes(TokenKind.LCurly))
{
if (lCurly.Next == null
|| !IsPreviousTokenOnSameLine(lCurly)
|| !(lCurly.Previous == null || IsPreviousTokenOnSameLine(lCurly))
|| lCurly.Next.Value.Kind == TokenKind.NewLine
|| lCurly.Next.Value.Kind == TokenKind.LineContinuation
|| lCurly.Next.Value.Kind == TokenKind.RCurly
Expand Down Expand Up @@ -616,7 +616,7 @@ private List<CorrectionExtent> GetCorrections(
}


private bool IsPreviousTokenOnSameLine(LinkedListNode<Token> lparen)
private static bool IsPreviousTokenOnSameLine(LinkedListNode<Token> lparen)
{
return lparen.Previous.Value.Extent.EndLineNumber == lparen.Value.Extent.StartLineNumber;
}
Expand Down
4 changes: 4 additions & 0 deletions Tests/Rules/UseConsistentWhitespace.tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,10 @@ if ($true) { Get-Item `
'@
Invoke-ScriptAnalyzer -ScriptDefinition $def -Settings $settings | Should -Be $null
}

It 'Should not throw when analysing a line starting with a scriptblock' {
{ Invoke-ScriptAnalyzer -ScriptDefinition '{ }' -Settings $settings -ErrorAction Stop } | Should -Not -Throw
}
}


Expand Down