Rule "Math operands should be cast before assignment" (squid:S2184) does not trigger

359 views
Skip to first unread message

nicola...@gmail.com

unread,
Dec 12, 2016, 9:42:30 AM12/12/16
to SonarQube
I recently found a statement where the rule squid:S2184 should have triggered in my opinion, but hasn't:
double dt2 = (1 / 2) * dt * dt * sigma * sigma; // dt, sigma are double

It turned out that as soon as there is a double value in the statement, the rule is not triggered, i.e.
double a = 1 / 2 * 5.0;

The language is Java, btw.

tibor.b...@sonarsource.com

unread,
Dec 15, 2016, 12:20:11 PM12/15/16
to SonarQube, nicola...@gmail.com
Hello,

seems you are right, there is a bug in the rule that such cases are not detected. I created the following ticket to handle it


Thank you for reporting the issue.

Best regards

Tibor BLENESSY | SonarSource
Software Engineer
Reply all
Reply to author
Forward
0 new messages