Open iRon7 opened 2 years ago
Asking on a per file basis was the easiest to implement because otherwise there are many different low level code paths for invoking rules as they are treated differently internally based on subtypes (custom rule vs DSC rule vs built in, etc.). But the real challenge to ask the user more specifically is that the rules are executed in parallel and result are later collected and merged. Therefore we'd need to have a different way of running rules individually, collecting the result, asking the user, applying the fix conditionally and then continuing just to be able to achieve what you want. I am not saying it's impossible but it is a LOT of plumbing work that potentially requires further refactoring to make it possible.
Maybe a better way to achieve the same result that you ask for is to collect diagnostic results first from Invoke-ScriptAnalyzer and then the user can pass them to a (new?) cmdlet to apply the correction or have an extension method on a diagnostic record to apply the suggested correction. What do you think about this?
Currently the
-Fix
-Confirm
(and-WhatIf
) common parameters aren't very specific on what and how PSScriptAnalyzer is about to correct the found violations:I would expect a more specific message of what and how a violation is changed, e.g.: