False positive with inner TheoryData classes

Make sure to read this post before raising a thread here:

Then tell us:

  • What language is this for?
    C#
  • Which rule?
    S1144
  • Why do you believe it’s a false-positive/false-negative?
    the code is compiled and executed properly
  • Are you using
    • SonarQube - 10.4.1
    • SonarLint - JetBrains
      • in connected mode with SonarQube
  • How can we reproduce the problem? Give us a self-contained snippet of code (formatted text, no screenshots)
public class Tests
{
    private class TestTheoryData : TheoryData<int, int>
    {
        public TestTheoryData()
        {
            Add(15, 25);
            Add(0, 99);
        }
    }

    [Theory]
    [ClassData(typeof(TestTheoryData))]
    public void Method_ShouldSucceed(int num1, int num2) 
    {
       var result = o.Method(num1, num2);
    }
    
}

TestTheoryData constructor is said never been called while it is (the test is properly performed)

Hey @Tetram76

We’ve fixed about 10 FP/FNs related to this rule since SonarQube v10.4.1. Can you upgrade to an active version of SonarQube (v10.6) and see if you can still reproduce the issue? In my (non-extensive) local tests so far, I cannot.

Hi,

Unfortunately, due to a dependency conflict, we can’t upgrade our instance yet.

However, thanks for the reply. It’s good to know you couldn’t reproduce the problem.
I will keep an eye on this until we upgrade our instance. I will open a new issue (or reopen this one if you prefer) if the problem is still there by then.

Regards.

This thread can stay open. :slight_smile: