Description
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 the DiagnosticRecord
object, it propose to have a new cmdlet (e.g. Invoke-ScriptAnalyzerWarningResolver
) to which the user can pass the DiagnosticRecord
object directly that the user received from Invoke-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?