Skip to content

Fixing PSAvoidTrailingWhitespace is broken #1757

Closed
@Ana06

Description

@Ana06

Using the Fix option for the PSAvoidTrailingWhitespace rule is broken.

Steps to reproduce

I have installed PSScriptAnalyzer v1.20.0 using chocolatey and run the following command in this folder: https://github.com/mandiant/VM-Packages/tree/2726fcde4bba996dcd446b240c3439a129ddba7d/packages

Invoke-ScriptAnalyzer . -Recurse -IncludeRule PSAvoidTrailingWhitespace -Fix

Expected behavior

I had expected this command to fix the offenses of the PSAvoidTrailingWhitespace rule.

Actual behavior

It removes } causing a MissingEndCurlyBrace parsing error, as you can see in the git diff:
Screenshot 2021-12-21 at 14 20 17

An <U+FEFF> is also added at the beginning of the modified files. This seems related to #1743

Environment data

> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      5.1.14409.1005
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.14409.1005
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.20.0

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions