PowerShell / PowerShell/PSScriptAnalyzer
Add a rule to alert `catch [RuntimeException] { ... }`
@JamesWTruher is already working on this.
Since Sep 27, 2022.
- Dominant language
- C#
- Stars
- 2.2k
- Forks
- 414
- Avg merge
- 13h 1m
- Merged PRs (30d)
- 2
Description
Summary of the new feature
In practice, catch [System.Management.Automation.RuntimeException] { ... } behaves the same as an unqualified catch block. That is, it catches any exception. See details in https://github.com/PowerShell/PowerShell/issues/16392.
Reason for that is explained in https://github.com/PowerShell/PowerShell/issues/16392#issuecomment-966712592.
Proposed technical implementation details (optional)
It would be nice to have a rule to caution against using RuntimeException as the type for a catch clause.
What is the latest version of PSScriptAnalyzer at the point of writing
1.20.0
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.