FindBugs is Java static analyzer, not Scala analyzer. Though you can feed FindBugs with scalac-generated bytecode, you will get the enormous number of false-positives and simply irrelevant reports, which makes it practically useless. Thus we are not going to fix something for the Scala code.
In Java the equivalent code produces a compilation error, thus no need to check it with FindBugs:
String a = "s";
Integer b = 42;
if(a != b) // error: incomparable types: String and Integer
System.out.println("bug");
If you use equals instead of !=, then FindBugs warns:
Call to String.equals(Integer) in test.Unrelated.main(String[])
Also FindBugs warns when you use the Object type:
Object a = "s";
Object b = 42;
if(a != b)
System.out.println("bug");
FindBugs warning:
Using pointer equality to compare a Integer with a String in test.Unrelated.main(String[])
So everything already works for Java and there's nothing to fix.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
FindBugs is Java static analyzer, not Scala analyzer. Though you can feed FindBugs with scalac-generated bytecode, you will get the enormous number of false-positives and simply irrelevant reports, which makes it practically useless. Thus we are not going to fix something for the Scala code.
In Java the equivalent code produces a compilation error, thus no need to check it with FindBugs:
If you use
equals
instead of!=
, then FindBugs warns:Also FindBugs warns when you use the
Object
type:FindBugs warning:
So everything already works for Java and there's nothing to fix.