- Description Catching an exception that is high up in the exception hierarchy (System.Exception & System.ApplicationException) is almost always a bad idea. It is quick but will make the code-base unreadable in the long run.
- Noncompliant Code Any code that catches System.Exception or System.ApplicationException
- Compliant Code Code that catches an exception derived from System.ApplicationException
- Edge Cases 1) Top-level exception handlers 2) Using exception filters
- Type : Bug
Based on my understanding I would say that rule S2221 does what you suggested. Please take a look at the rule and correct me if I misunderstood something.
I didn’t know that one - thanks for pointing that out.
If you already have that rule in place I wonder why I haven’t ever seen it in my reports.
Could it be that its not triggering? If so, how would I find out? I do know for a fact that I have that problem multiple times throughout my codebase. (Hence the suggestion for the rule )
Also, do you have a way to search for violations of a rule by its code “S2221”?
S2221 is not part of the default quality profile, so you have to add it to the profile you are using in order to execute it.
Yes, if you open the Rules tab you can search for the rules based on their rule id.
If you have any trouble adding the rule to your quality profile or struggle finding the way to search for a rule by its id, please provide me the information about which product you are using (together with the version number) and I will be pleased to help.
thanks for pointing out that its not part of the standard set. I didn’t know that there are some rules which you don’t run by default.
I went ahead and enabled a bunch.
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.