You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When you use the Profile parameter, but the value is invalid (hash table, variable containing a hash table, incorrect key name), PSScriptAnalyzer generates a warning, but continues to run the test.
Because the profile is the user's instruction for running the test, when Invoke-ScriptAnalyzer cannot follow that instruction for any reason, the test should immediately fail with a terminating error.
Otherwise, you waste the user's time running the wrong test and, more importantly, if the user has logged output and not examined the warning/error stream, the user might not know that the test they ran was not the test they designed.
Be sure that the error message helps the user to solve the problem. For example, list the valid keys in a profile hash table, rather than just telling the user that the key is invalid.
The text was updated successfully, but these errors were encountered:
Summary of changes - Let us know if have any input
For an invalid profile - emit non-terminating errors for each issue in Profile and stop the Engine execution - This will prevent any rules from running
For a profile containing combination of valid and invalid keys, emit Warnings for invalid keys, but continue the execution. The Warnings will contain additional info about the Keys supported
Why use a warning for an invalid key? The user intended to do something and it failed, so the output is not what they wanted. I think generating output in this situation is confusing. Also, warnings are not widely used in PowerShell. If we don't generate a terminating error, we should generate a non-terminating error.
We want the Engine to be flexible and continue execution as long as it received the correct set of keys. For non-existent/invalid keys, our thinking was to inform the user as a warning since it is simply an anomaly in the input.
I do agree that we have to be consistent in handling all invalid user input across ScriptAnalyzer (ScriptPaths, CustomRulePaths, Profiles, Rule filters etc)
So in this case, we can do #1
(emit non-terminating errors for each issue in Profile and stop the Engine execution - This will prevent any rules from running)
When you use the Profile parameter, but the value is invalid (hash table, variable containing a hash table, incorrect key name), PSScriptAnalyzer generates a warning, but continues to run the test.
Because the profile is the user's instruction for running the test, when Invoke-ScriptAnalyzer cannot follow that instruction for any reason, the test should immediately fail with a terminating error.
Otherwise, you waste the user's time running the wrong test and, more importantly, if the user has logged output and not examined the warning/error stream, the user might not know that the test they ran was not the test they designed.
Be sure that the error message helps the user to solve the problem. For example, list the valid keys in a profile hash table, rather than just telling the user that the key is invalid.
The text was updated successfully, but these errors were encountered: