-
Notifications
You must be signed in to change notification settings - Fork 498
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
Restore default PSScriptAnalyzer ruleset #246
Comments
Apologies for that, we have changed to a different method for integration PowerShell Script Analyzer and didn't carry over the default ruleset we were using before. I'll address this in a patch release in a few days. |
This change restores the default set of rules that we previously used in our PSScriptAnalyzer integration. This list got removed inadvertently when we changed our design to consume PSScriptAnalyzer as a module rather than a C# API. Related to PowerShell/vscode-powershell#246
This change restores the default set of rules that we previously used in our PSScriptAnalyzer integration. This list got removed inadvertently when we changed our design to consume PSScriptAnalyzer as a module rather than a C# API. Related to PowerShell/vscode-powershell#246
Fixed in the latest release! |
@daviwil personally i dont feel this is "fixed" as realistically the default ruleset should be to have any rules that emit warnings or errors throw - exactly as it would be if you just ran Invoke-ScriptAnalyzer -Severity Error,Warning We then can allow users like @alejandro5042 to disable the Aliases rule using their own rulesets but for the greater good of the community and those new to PowerShell they need to be warned about the fact that aliases can break scripts. For example I regularly see organisations deploy as part of their base OS images a $PROFILE.AllUsersAllHosts that includes Remove-Item Alias:\* -force would break all of @alejandro5042 scripts and is exactly why you should never use aliases. Happy to raise this as another issue but I feel that pleasing 1 user in this case @alejandro5042 isn't in the best interests of the community especially now that it is going to start growing even bigger. |
I know I have already voiced my opinion on the other thread. I'm afraid the use of aliases is "religious" in nature and we'll only have to agree to disagree.
Why should I--an unrelated user--have to support the workflow of someone who is intentionally removing all their aliases? Aliases are part of the PowerShell language and are extremely useful for day-to-day usage. I shouldn't have to pay the penalty because you don't like a built-in language feature. For example, take this very specific, very simple command, and see how using aliases blows it up into something that's unapproachable and difficult to read.
vs.
Now I understand, I'm primarily a C# coder and in C# we spell everything out. But I use PowerShell as a scripting environment where things should be easy and fast. Again, we can agree to disagree. |
IMO the extension shouldn't be super opinionated about this argument but it should make it easy for folks to get what they want. Today, it's perhaps not as obvious as I'd like but you can create your own ruleset file and apply it globally to VSCode on your machine or to a specific workspace by adding and configuring the setting in your user settings file (or workspace settings file for the project specific ruleset - my favorite approach):
The ruleset file is pretty simple:
The deal with toning down the PSSA errors/warnings early on was due to A) PSSA was highlighting way too much source. For instance, an unapproved verb caused the whole function definition to be squiggled. PSSA has fixed a number of those "extent" issues. B) PS on Linux had not been announced and the issue with aliases was not as, um, critical as it appears to be at the moment. All that said, I'm not opposed to adding back the |
I agree with waiting to see how the issue settles with PowerShell proper. Naturally, the editor should support whatever default the community decides--but make it easy to override. |
@rkeithhill is correct, the main reason for cutting down the list of rules to a small set is that there was a lot of marker noise showing up in the average PowerShell file. However, I do think it'd be great if you want to start a separate issue on this repo to get some community consensus about what that default ruleset should be. I am happy to change it to whatever people think is the right default set of rules for the editing experience. |
I want to use aliases, but as of today's update, I am getting underlines all over my source. They are very distracting and I cannot find a way to disable them. Is there an option? If not, I propose this being an issue that should be fixed.
The text was updated successfully, but these errors were encountered: