-
Notifications
You must be signed in to change notification settings - Fork 395
Feature idea: Auto-Correct warnings #802
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
Comments
Hey @bergmeister, adding something to PSScriptAnalyzer that fixes such warnings will be great! We already do that in the I think we have 3 options to tackle this problem:
We have been thinking about this for a while and I think the best approach right now would be to have a Regarding the first option, the biggest problem with only handling The second option is somewhat reasonable but it would involve a lot of duplication from the |
OK. It was interesting to read your thoughts (and I also learned about |
I must've forgotten to include information regarding Regarding I would recommend the implementation to be similar to how the
Contributions are always welcome - I am just trying to make sure that we keep things consistent functionality and implementation wise. |
@kapilmb : I have committed now the minimum viable feature in my fork here. I had a look at the code structure and |
@bergmeister Sorry I haven't been able to devote much time here. I just went through your changes and left some comments. I would still prefer the |
Add Fix switch parameter for 'File' parameter set to auto-correct warnings (#802)
Will close now since the PR was merged. |
Uh oh!
There was an error while loading. Please reload this page.
PSScriptAnalyzer already suggests possible fixes and for certain warnings like e.g.
PSAvoidUsingCmdletAliases
there is only solution for a fix (apart from suppressing it).I have already created a working prototype of PSScriptAnalyzer that automatically corrects
PSAvoidUsingCmdletAliases
and would be happy to do a PR for that.Would you be happy with that and if so, how should this feature be used? My first thought was to not add a switch in
Invoke-ScriptAnalyzer
because then we would need to modify the returned object in a way to tell the user that PSScriptAnalyzer has tried to resolve the warning and tell the user to check if he/she is happy with it. Because all the essential information is in theDiagnosticRecord
object, it propose to have a new cmdlet (e.g.Invoke-ScriptAnalyzerWarningResolver
) to which the user can pass theDiagnosticRecord
object directly that the user received fromInvoke-ScriptAnalyzer
. For convenience another parameter set specifying the file(s) or folder (optionally recursively) might be useful as well. The new cmdlet should return a DiagnosticRecord as well with a description and a line diff (before/after) of the applied changes.What are your thoughts on it?
The text was updated successfully, but these errors were encountered: