Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Severity Level: Information
Description
This rule detects lines that end with trailing whitespace characters. Lines shouldn't end with trailing whitespace characters. Trailing whitespace makes diffs harder to review and can introduce subtle problems when line continuation uses a backtick (`), because the backtick must be the last character on the line.
Keeping lines free of trailing whitespace improves readability and helps keep source control history clean.
To learn more, see about_Parsing.
Example
Noncompliant
# The next line ends with a trailing space after the backtick.
Get-Process `
| Where-Object { $_.CPU -gt 100 }
When you run this script, PowerShell throws a parser error because the trailing space prevents line continuation. For example:
PS C:\WINDOWS\system32> Get-Process `
| Where-Object { $_.CPU -gt 100 }
At line:2 char:1
+ | Where-Object { $_.CPU -gt 100 }
+ ~
An empty pipe element is not allowed.
+ CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : EmptyPipeElement
Compliant
Get-Process `
| Where-Object { $_.CPU -gt 100 }