[Mono-bugs] [Bug 567817] New: CheckParametersNullityInVisibleMethodsRule has false positives when using return

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Thu Dec 31 12:13:58 EST 2009


http://bugzilla.novell.com/show_bug.cgi?id=567817

http://bugzilla.novell.com/show_bug.cgi?id=567817#c0


           Summary: CheckParametersNullityInVisibleMethodsRule has false
                    positives when using return
    Classification: Mono
           Product: Mono: Tools
           Version: 2.6.x
          Platform: x86-64
        OS/Version: Windows 7
            Status: NEW
          Severity: Minor
          Priority: P5 - None
         Component: Gendarme
        AssignedTo: mono-bugs at lists.ximian.com
        ReportedBy: david at dasz.at
         QAContact: mono-bugs at lists.ximian.com
          Found By: Community User
           Blocker: No


Description of Problem:

The following method triggers a CheckParametersNullityInVisibleMethodsRule hit
although it is perfectly safe:

        public virtual void Add(TInterface item)
        {
            if (item == null)
            {
                underlyingCollection.Add(null);
                return;
            }
            else
            {
                if (ctx != item.Context) { throw new Exception(); }

                underlyingCollection.Add((TImpl)item);
            }
        }

I presume that the rule is confused by the conditional return?

Actual Results:

Target: System.Void YYYYYYYYYY`2::Add(TInterface)
Assembly: AAAAAAAAAAAAA, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null

Severity: High  Confidence: Normal
Location: item
Source: AAAAAAAA\YYYYYYYYYYY.cs(≈36)

Expected Results:

No match of the rule on the function, since the function returns without using
"item" if it is null.

How often does this happen? 

every time. I also tried the function with a different structure (no "else",
throwing a exception after the first if) but to no avail.

Additional Information:

I tested this with both Gendarme 2.4 and the 2.6 preview available from ohlo.







PS: novell's bugzilla sign-up process is mightily annoying.

-- 
Configure bugmail: http://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.


More information about the mono-bugs mailing list