Open
Description
There is a rule for The Try statement is missing its Catch or Finally block.:
Invoke-ScriptAnalyzer -ScriptDefinition {function Test { Try { write-verbose 'Test' } }}.ToString()
ParserError:
Line |
1 | … criptDefinition {function Test { Try { write-verbose 'Test' } }}.ToSt …
| ~
| The Try statement is missing its Catch or Finally block.
But there is no rule for the opposite: a Catch
(or Finally
) statement that is missing its Try
block:
Invoke-ScriptAnalyzer -ScriptDefinition {function Test { Catch { write-verbose 'Test' } }}.ToString()
Even it produces a syntax error during run time (as it assumes it is a cmdlet, which is definitely not a recommend function name):
Catch { write-verbose'Test' }
Catch: The term 'Catch' is not recognized as a name of a cmdlet, function, script file, or executable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
Metadata
Metadata
Assignees
Labels
No labels