S2259 in Community Edition v9.9.5 (build 90363)

Versions:

  • SonarQube Community Edition v9.9.5 (build 90363)
  • SonarScanner for MSBuild 10.3

The following excerpt of code does not result in S2259 being flagged, which is a false negative:

var subscriptionItem = subscription.Items.FirstOrDefault();
var subscriptionPrice = subscriptionItem?.Price;

transaction.Currency = subscriptionPrice.Currency.ToUpper(); // subscriptionPrice could be null here

I’ve found other posts on the forum re: this issue in other products, e.g. SonarLint: Using c# null conditional operator breaks the rule analysis

I expect that the issue is fixed, but can’t find anything concrete about when it was fixed, i.e. which version.

Could you please assist?

Many thanks,

Antony

Hi,

Welcome to the community!

Only the latest version of SonarQube Community Build is considered active, so you’ll need to update and see if the situation is still replicable before we can help you.

Your update path is:

9.9.5 → 24.12 → 25.6

You may find these resources helpful:

If you have questions about upgrading, feel free to open a new thread for that here.

Since there have been many, many rule updates since 9.9, it’s quite likely you’ll find this is fixed once you’re on a current version. However, if that’s not the case, please do come back to us.

 
Ann

Hi @ganncamp,

Thanks for coming back to me.

Thanks for the clarification re: the active version. I tried to look for an active version policy for Community Build, but could only find these docs which say that there is no such concept: SonarQube Community Build release cycle model

I have run the latest version locally and found that this rule no longer appears to be included in Community Build. I have checked this against the documentation and that appears to be correct - S2259 now only appears in SQ Cloud and Server: C# static code analysis

Is there a way of knowing why a rule was removed and whether an alternative rule has been added in its place?

Many thanks,

Antony

Hi Antony,

That’s right, the only ‘active’ version for Community Build is the latest one.

With the full split into Community Build and Server, some C# rules were removed from Community Build, and that was announced at the time. Essentially, it was a mistake that they were ever exposed in non-commercial editions that was corrected at the re-packaging.

 
HTH,
Ann

Hi @ganncamp

That’s great, thanks for your help.

I’ve done some more digging on the forum and have found the following post, which includes a list of rules dropped from Community: Which .NET rules were dropped in Community Build? - SonarQube Server / Community Build - Sonar Community

Adding here for anyone who comes across this question and finds the information useful.

Many thanks,

Antony

1 Like