Overlap between S112 and CA2201

Rule S112 is useful rule, helping developers to use the appropriate exceptions. For .NET hower, Microsoft’s CA2201 seems to be doing (more or less), the same thing.

Are you aware of that?

Furthermore, it might be worth to mention CA2201 in RSPEC, so that developers can disable one of them, to prevent double reports on issues.

Anyone?

Hi @Corniel, sorry for the delay.

The two rules indeed seem to be identical. I made the .NET product manager aware of it; He will take a decision on what to do.

Hi Corniel,

Sorry for the delay in responding, I was on holiday.
To your point, CA2201 is not enabled by default by Microsoft while S112 is (being in SonarWay).
You are right that there IS duplication in that case, and I think we need to keep S112 so that users of the default setup can benefit from it.
As for pointing out CA2201 in the RSPEC so people can make sure they do not activate it so they can avoid double reporting, it might be a good idea. I will record this in our systems for consideration (for all rules that have the same problem).

Thank you for bringing this to our attention!

Denis

2 Likes