Closed
Description
Steps to reproduce
Using Invoke-Formatter
does not apply the PSAvoidTrailingWhitespace
rule as shown by the following example script:
$script = @"
Function Get-Example {
'Example'
}
"@
$settings = @{
IncludeRules = @("PSAvoidTrailingWhitespace")
}
$formatted = Invoke-Formatter -ScriptDefinition $script -Settings $settings
Out-File -FilePath ./result.ps1 -InputObject $formatted -Encoding utf8 -NoNewline
Invoke-ScriptAnalyzer -Path ./result.ps1
Expected behavior
# There should be no linting results after formatting
Actual behavior
# There are linting results even after formatting
RuleName Severity ScriptName Line Message
-------- -------- ---------- ---- -------
PSAvoidTrailingWhitespace Information result.ps1 1 Line has trailing whitespace
PSAvoidTrailingWhitespace Information result.ps1 2 Line has trailing whitespace
PSAvoidTrailingWhitespace Information result.ps1 3 Line has trailing whitespace
Environment data
> $PSVersionTable
Name Value
---- -----
PSVersion 5.1.22621.2506
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.22621.2506
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
> (Get-Module -ListAvailable PSScriptAnalyzer).Version | ForEach-Object { $_.ToString() }
1.22.0