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
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.
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.
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?
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.