IDEA-140398 (Inspection "Floating point value comparison" should ignore comparison with integer 0)

This commit is contained in:
Bas Leijdekkers
2015-05-20 16:33:30 +02:00
parent a5275c67eb
commit d98a4c282a
2 changed files with 12 additions and 2 deletions
@@ -1,5 +1,5 @@
/*
* Copyright 2003-2014 Dave Griffith, Bas Leijdekkers
* Copyright 2003-2015 Dave Griffith, Bas Leijdekkers
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -78,6 +78,14 @@ public class FloatingPointEqualityInspection extends BaseInspection {
final float v = aFloat.floatValue();
return Float.isInfinite(v) || v == 0.0f;
}
else if (value instanceof Integer) {
final Integer integer = (Integer)value;
return integer.intValue() == 0;
}
else if (value instanceof Long) {
final Long aLong = (Long)value;
return aLong.longValue() == 0;
}
return false;
}
}
@@ -31,7 +31,9 @@ public class FloatingPointEquality
boolean infinity = m_bar == Double.POSITIVE_INFINITY;
boolean zero = m_barf == 0.0f;
boolean zero2 = m_barf == 0;
boolean zero3 = m_barf == 0L;
}