mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-140398 (Inspection "Floating point value comparison" should ignore comparison with integer 0)
This commit is contained in:
+9
-1
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
+3
-1
@@ -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;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user