C# 'Calculations should not overflow' rule is changing

Hi .NET Folks

I’d like to update you on our plans for the rule ‘calculations should not overflow’. We think this is a valuable rule but are not satisfied with its current accuracy, and for this reason, it’s not part of the Sonarway profile. After the release of the upcoming SonarQube LTS, during the 10.x cycle, we plan to change the way it works by using features available in more recent versions of the Roslyn compiler. These changes will improve the precision of the rule, remove the Windows-only limitations and also bring the rule directly to your IDE via SonarLint or NuGet package.

The tradeoff for the increased accuracy is that this rule will require a build using MSBuild 15+. Once this is done builds using older MSBuild versions will not raise issues for this rule. Until then you can continue to use this rule as you do now.

3 Likes

Hello again

The ‘calculations should not overflow’ rule has now been updated and you should see a big improvement in its detection and precision, particularly on newer versions of .NET. The rule is now part of the Sonarway profile. As previously mentioned the rule now requires a build using MSBuild 15+.

This update is on SonarCloud today and will be in the upcoming SonarQube 10.1 as well as upcoming releases on SonarLint.

Let me know if you have any feedback or questions.

Tom

1 Like

Let’s make sure this never happens again:

For context:
This is Ariane 5 flight V88 - The most infamous and expensive software bug in history. It was caused by an integer overflow!

2 Likes