SonarQube raises the major violation Silly math should not be performed in my code. The description says
Certain math operations are just silly and should not be performed because their results are predictable.
In particular,
anyValue
% 1 is silly because it will always return 0.
In my case though, anyValue
is a double. And this works as intended for me. Here's the actual code:
double v = Double.parseDouble(Utils.formatDouble(Double.valueOf(value.getValue()), accuracy.intValue()));
boolean negative = v < 0;
v = Math.abs(v);
long deg = (long) Math.floor(v);
v = (v % 1) * 60;
Is the analyser assuming my variable is an int
(which is their bug)? Or am I missing something else?