I’m getting what I think is a false positive for this rule:
Reserved identifiers and functions in the C stand#ard library should not be defined or declared
The following code triggers it – I’m using local aliases to make the code more readable:
#include <cmath>
struct Coord { double azimuth; double elevation; };
double myFunction(const Coord& a, const Coord& b)
{
using std::sin; // this triggers cpp:S978
using std::cos; // this triggers cpp:S978
return (sin(a.elevation) * sin(b.elevation) +
cos(a.elevation) * cos(b.elevation) * cos(a.azimuth - b.azimuth));
}
I think for local (within function) aliases like this, this rule should not be applied.
A workaround would be to add a using std::namespace
within this function, but I don’t see the harm in using function aliases instead.
I’m on Sonarqube Developer Edition - Version 9.9 (build 65466)