-
Notifications
You must be signed in to change notification settings - Fork 382
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
Allow formatter to optionally correct aliases #1277
Allow formatter to optionally correct aliases #1277
Conversation
@bergmeister my real concern is the inclusion of this sole rule as an option. Shouldn't we allow any/all the rules to be run? |
Yes, I agree but addressing this technical debt of PSSA's architectural design is non trivial and is a separate issue to me. With this proposed change I'm not adding to the debt. |
@bergmeister Would you be able to put in one or more issues to fix this particular case of PSScriptAnalyzer's architectural debt? I'd like to take a crack at fixing it myself (or at least jump-start a discussion), considering that I'm looking at extending the PSScriptAnalyzer<=>PowerShellEditorServices interface regarding completions and intellisense sometime over the next few months. |
@travis-c-lagrone The debt is that the formatter has a list of hard coded rules that it can execute only. As said before, it should be improved so that whilst we might still want to have a hard-coded list of 'default' rules, it would be nice that if one specified any rule in the settings file/object that Invoke-formatter executes them. It would need some research as to why this is the case, I don't know more than that. |
Two questions:
|
Yes, SMA is |
When does the PSSA team plan to make the bump to PSSA 2.0? And is there a list of changes somewhere that will/can/should be made concurrently to take advantage of that bump? |
PR Summary
Invoke-Formatter
has a hard-coded list of rules that is supports. Add support forPSAvoidUsingCmdletAliases
as the community has expressed interest in being able to auto-replace them when formatting in VS-Code (optionally, not on by default).https://twitter.com/PrzemyslawKlys/status/1144342766408937490
Although
Invoke-ScriptAnalyzer
has a-Fix
switch, the switch is only on for the-Path
parameter set, therefore being able to optionally run this rule in the formatter is going to make it easier in the future to add a setting to vs code to optionally correct aliases. This change does not change the defaults behavior ofInvoke-Formatter
, it enables the following scenario to workYes, the current debt of the code base is not ideal that invoke-formatter has the allowed rules hard-coded but given the narrow use case of it, refactoring it would be a separate item. I cannot even improve it to use resource strings because they are in the Rules project and the Rules project has a dependency on the Engine project (or would you want me to move the resource strings into the Engine project?)
cc @PrzemyslawKlys
PR Checklist
.cs
,.ps1
and.psm1
files have the correct copyright headerWIP:
to the beginning of the title and remove the prefix when the PR is ready.