I’m using SonarQube sonarqube-8.2.0.32929 community edition, sonar scanner sonar-scanner-msbuild-4.7.1.2311-net46
The warning for the rule S3949: Calculations should not overflow (Category: Bug) is not caught by sonar scanner and it is not displayed in the report.
E.g. Analyzing :
/// <title>Calculations should not overflow</title>
/// <summary>
/// Numbers are infinite, but the types that hold them are not. Each numeric type has hard upper and lower bounds.
/// Try to calculate or assign numbers beyond those bounds, and the result will be a value that has silently wrapped
/// around from the expected positive value to a negative one, or vice versa.
/// </summary>
namespace SonarQubeToolVerification.Bug.Warnings
{
public class S3949Warning
{
public int getTheNumber(int val)
{
if (val <= 0)
{
return val;
}
int num = int.MaxValue;
return num + val; // Noncompliant
}
}
}
Waiting for Bug warning:
S3949: Calculations should not overflow
but nothing displayed in the report.
Any suggestions?