Hi! I’m trying to find the equivalent of CA2000 in SonarQube, but haven’t had any luck. Any ideas how this can be achived? Thanks!
I assume we’re talking about C#? We have a number of rules around the proper use of
iDisposable. I suppose this one is the most directly relevant:
“IDisposables” should be disposed
Thanks for your reply! Yes, I’m talking about C#.
I was looking at that rule and it would work, however, it only tracks specific types.
This rule tracks
privatefields and local variables of the following
IDisposabletypes, which are never disposed, closed, aliased, returned, or passed to other methods.
I have a situation where an IDisposable type that is not in that list was not disposed and was causing a memory leak.
Thanks for the pointer. Let’s wait for the language specialists to get here. I’m sure they’ll be interested in this.
I was wondering if you could take a quick look at my question.
I understand your impatience, but please don’t invoke people who aren’t already participating in a thread.
The language developers make a point of monitoring the community, but they do so… in their own time.
And for transparency, we just finished the big annual company event & everyone’s been focused on preparing for & participating in that for a while now.
We do not have a rule with an exact match for CA2000. However, there is rule S2931 which covers the case of having IDisposable members inside a class, and there is the rule suggested by @ganncamp which as you already saw covers only part of the CA2000 functionality.
Thanks for getting back to me and sorry for pulling you into the thread like I did.
We have both of the rules mentioned activated and neither of them flagged the issue. I think it’s because the variable is scoped to the function and is not a class property or variable. Could this be a blind spot with the current rules?
Yes, it indeed is. We are very thankful to you for helping us find this blind spot.
Together with other team members we will revisit all our IDisposable related rules and we will try to find a way to cover this blind spot (Maybe we will change one of the existing rules or we will add a new one, we have not yet decided).
I’m happy I can help. Is there a way for me to follow the development of this issue? Is that kind of information public?
Thank you @Caba_Sagi!
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.