Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

The PSAvoidTrailingWhitespace rule is not applied when using Invoke-Formatter #1992

Copy link
Copy link
@Ju-l1a

Description

@Ju-l1a
Issue body actions

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.