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

Auto-fix PSSA warnings #41

Closed
wants to merge 3 commits into from

Conversation

bergmeister
Copy link
Contributor

@bergmeister bergmeister commented Dec 13, 2018

Auto-fix PSSA warnings:

  • Use proper cmdet name instead of alias for better readability and slightly faster runtime performance due to faster command lookup
  • Remove trailing whitespace, resulting in a smaller payload of the whole module and git repo

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; }

…se | % { $c = cat $_.FullName -Raw; Set-Content -Path $_.fullname -Encoding Ascii -Value $c -NoNewline; }
@bergmeister bergmeister reopened this Dec 13, 2018
@nohwnd
Copy link
Owner

nohwnd commented Dec 14, 2018

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
Copy link
Contributor Author

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
Copy link
Owner

nohwnd commented Dec 14, 2018 via email

@bergmeister
Copy link
Contributor Author

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants