PSAvoidTrailingWhitespace: Rule not applied when using formatter + single character lines with trailing whitespace are truncated by liamjpeters · Pull Request #1993 · PowerShell/PSScriptAnalyzer · GitHub
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
1 change: 1 addition & 0 deletions Engine/Formatter.cs
2 changes: 1 addition & 1 deletion Rules/AvoidTrailingWhitespace.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public IEnumerable<DiagnosticRecord> AnalyzeScript(Ast ast, string fileName)
}

int startColumnOfTrailingWhitespace = 1;
for (int i = line.Length - 2; i > 0; i--)
for (int i = line.Length - 2; i >= 0; i--)
{
if (line[i] != ' ' && line[i] != '\t')
{
Expand Down
25 changes: 25 additions & 0 deletions Tests/Rules/AvoidTrailingWhitespace.tests.ps1