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
30 changes: 30 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"version": "0.2.0",
"configurations": [

{
"name": ".NET Core Launch (console)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
"program": "${workspaceRoot}/bin/Debug/<target-framework>/<project-name.dll>",
"args": [],
"cwd": "${workspaceRoot}",
"externalConsole": false,
"stopAtEntry": false,
"internalConsoleOptions": "openOnSessionStart"
},
{
"name": ".NET Core Attach",
"type": "coreclr",
"request": "attach",
"processId": "${command:pickProcess}"
},
{
"name": ".NET Full Attach",
"type": "clr",
"request": "attach",
"processId": "${command:pickProcess}"
}
]
}
2 changes: 1 addition & 1 deletion Engine/EditableText.cs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public bool IsValidRange(Range range)

return range.Start.Line <= Lines.Count
&& range.End.Line <= Lines.Count
&& range.Start.Column <= Lines[range.Start.Line - 1].Length
&& range.Start.Column <= Lines[range.Start.Line - 1].Length + 1
&& range.End.Column <= Lines[range.End.Line - 1].Length + 1;
}

Expand Down
3 changes: 2 additions & 1 deletion Rules/UseConsistentWhitespace.cs
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,8 @@ private IEnumerable<DiagnosticRecord> FindOperatorViolations(TokenOperations tok
}

var hasWhitespaceBefore = IsPreviousTokenOnSameLineAndApartByWhitespace(tokenNode);
var hasWhitespaceAfter = IsPreviousTokenOnSameLineAndApartByWhitespace(tokenNode.Next);
var hasWhitespaceAfter = tokenNode.Next.Value.Kind == TokenKind.NewLine
|| IsPreviousTokenOnSameLineAndApartByWhitespace(tokenNode.Next);

if (!hasWhitespaceAfter || !hasWhitespaceBefore)
{
Expand Down
9 changes: 9 additions & 0 deletions Tests/Rules/UseConsistentWhitespace.tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,15 @@ $x = 1
'@
Invoke-ScriptAnalyzer -ScriptDefinition $def -Settings $settings | Should Be $null
}

It "Should not find violation if a binary operator is followed by new line" {
$def = @'
$x = $true -and
$false
'@
Invoke-ScriptAnalyzer -ScriptDefinition $def -Settings $settings | Should Be $null
}

}

Context "When a comma is not followed by a space" {
Expand Down