nohwnd / Assert

A set of advanced assertions for Pester to simplify how you write tests.
MIT License
101 stars 12 forks source link

Auto-fix PSSA warnings #41

Closed bergmeister closed 5 years ago

bergmeister commented 5 years ago

Auto-fix PSSA warnings:

I did this as follows to preserve existing Ascii encoding:

Invoke-ScriptAnalyzer . -Recurse -Fix;  gci -File -Filter *.ps1  -Recurse | % { $c = cat $_.FullName -Raw; Set-Content -Path $_.fullname -Encoding Ascii -Value $c -NoNewline; }
nohwnd commented 5 years ago

I couldn't find any files in the project that are ASCII, the sizable amount I checked were all in UTF8 without BOM. Are you sure ascii is correct? I tested it now with utf8 and the module seems to work just fine after the fixes.

powershell -NoProfile -Command Invoke-ScriptAnalyzer . -Recurse -Fix

Btw how long it takes to finish on your computer? Here it takes a minute or maybe even two. Is it normally that slow?

bergmeister commented 5 years ago

In the diff presented by Tortoise Git, it seemed to be that previosly it was Ascii, hence why I changed it back to Ascii. However, by looking at the Encoding of master in Notepad++ it seems to be UTF8-BOM. When I wrote the -Fix switch I tried to preserve encoding as good as possible when reading and writing to the file so maybe TortoiseGit is just wrong when it shows me the diff, I'll revert the encoding change.

nohwnd commented 5 years ago

When I look at any file I see just UTF8 without BOM. If there are files with BOM then they should become UTF8 without BOM anyway.

On 14 Dec 2018, at 19:34, Christoph Bergmeister [MVP] notifications@github.com<mailto:notifications@github.com> wrote:

In the diff presented by Tortoise Git, it seemed to be that previosly it was Ascii, hence why I changed it back to Ascii. However, by looking at the Encoding of master in Notepad++ it seems to be UTF8-BOM. When I wrote the -Fix switch I tried to preserve encoding as good as possible when reading and writing to the file so maybe TortoiseGit is just wrong when it shows me the diff, I'll revert the encoding change.

— You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://github.com/nohwnd/Assert/pull/41#issuecomment-447414195, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AFeF4ZmTH9ByqSTiYjyL25zZdIsW6yn-ks5u4-8wgaJpZM4ZSPdm.

bergmeister commented 5 years ago

Ok, I'll close this in favour of PR #43 where I don't change the encoding. Changing the encoding is a bit tricky, so I'll leave that up to you then (I tried different techniques but different editors were showing me different values)