Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing PSAvoidTrailingWhitespace is broken #1757

Open
Ana06 opened this issue Dec 21, 2021 · 1 comment · May be fixed by #1993
Open

Fixing PSAvoidTrailingWhitespace is broken #1757

Ana06 opened this issue Dec 21, 2021 · 1 comment · May be fixed by #1993

Comments

@Ana06
Copy link

Ana06 commented Dec 21, 2021

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
@ghost ghost added the Needs: Triage 🔍 label Dec 21, 2021
@Ana06 Ana06 changed the title Fixing`PSAvoidTrailingWhitespace is broken FixingPSAvoidTrailingWhitespace is broken Dec 21, 2021
@Ana06 Ana06 changed the title FixingPSAvoidTrailingWhitespace is broken Fixing PSAvoidTrailingWhitespace is broken Dec 21, 2021
@StevenBucher98
Copy link
Collaborator

Thanks for bringing this to our attention @Ana06! We are unsure when we will be able to fix this issue but have marked in up for grabs for community fixes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment