Simple reproducer:
void main() {
doSomething(10);
}
void doSomething(final int i) {
this.doSomethingElse(i);
}
void doSomethingElse(final float f) {
IO.println(f);
}
This results in a single finding when scanned:
(6, 25) Explicitly cast this "int" to "float" to document potential precision loss. [java:S9395]
So I follow this advice and insert an explicit cast:
void main() {
doSomething(10);
}
void doSomething(final int i) {
this.doSomethingElse((float) i); // Explicit cast inserted
}
void doSomethingElse(final float f) {
IO.println(f);
}
But upon rescanning, I get a different finding:
(6, 25) Remove this unnecessary cast to "float". [java:S1905]
So Iām kind of stuck ![]()
These two rules seem to clash here.