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
save it as a file, then run Invoke-ScriptAnalyzer against it.
Expected behavior
An error should be displayed, saying that there's no 'try' block, just 'catch'.
Actual behavior
No error is returned and the script throws an error when executed.
catch : The term 'catch' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a p
again.
At C:\Users\mchojnac\Desktop\test.ps1:2 char:1+catch {
+ ~~~~~
+ CategoryInfo : ObjectNotFound: (catch:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
This is a fairly strange one — I'm not sure how many people are accidentally using just a catch block. And by itself, catch is a valid command name.
With that said, it might be useful to warn about commands that could also be keywords. That could also solve #1571.
However, given we don't know there's much demand for this and that we're not working on feature requests like this currently, I'll mark this issue as up-for-grabs.
Steps to reproduce
save it as a file, then run Invoke-ScriptAnalyzer against it.
Expected behavior
An error should be displayed, saying that there's no 'try' block, just 'catch'.
Actual behavior
No error is returned and the script throws an error when executed.
Environment data
The text was updated successfully, but these errors were encountered: