11// probable-bugs.sandbox-hint — Probable Bug Patterns
2- // Detects code patterns that are likely programming mistakes
2+ // Detects code patterns that are likely programming mistakes.
3+ //
4+ // Keep this bundled library binding-safe for mining. Rules that rely on
5+ // distinguishing arrays from ordinary objects must not be active until the
6+ // standalone mining parser provides reliable type bindings or a strict type
7+ // guard is available.
38
49<!id: probable-bugs>
510<!description: Probable bug detection patterns>
611<!severity: warning>
712<!minJavaVersion: 8>
813<!tags: bugs, correctness>
914
10- // Hint-only: $x == $x on floating-point may be NaN check
11- "Comparing a value to itself — use Double.isNaN() or Float.isNaN() for NaN checks":
15+ @id: probable-bugs.self-comparison.review
16+ @severity: warning
17+ "Comparing a value to itself — use Double.isNaN() or Float.isNaN() for intentional NaN checks.":
1218$x == $x
1319;;
1420
15- // Hint-only: $x != $x on floating-point is NaN check
16- "Value not equal to itself — use Double.isNaN() or Float.isNaN() instead":
21+ @id: probable-bugs.self-inequality.review
22+ @severity: warning
23+ "Value not equal to itself — use Double.isNaN() or Float.isNaN() for intentional NaN checks.":
1724$x != $x
1825;;
1926
20- // Hint-only: $x.equals($x) is always true (reflexive)
21- "Object.equals() with same argument on both sides — always true, probably a bug":
27+ @id: probable-bugs.reflexive-equals.review
28+ @severity: warning
29+ "Object.equals() with the same expression on both sides is always true and often indicates a copy-paste bug.":
2230$x.equals($x)
2331;;
2432
25- // Hint-only: Math.max with identical arguments
26- "Math.max() with identical arguments — probably a copy-paste bug":
33+ @id: probable-bugs.math-max-identical-args.review
34+ @severity: warning
35+ "Math.max() with identical arguments — probably a copy-paste bug.":
2736java.lang.Math.max($a, $a)
2837;;
2938
30- // Hint-only: Math.min with identical arguments
31- "Math.min() with identical arguments — probably a copy-paste bug":
39+ @id: probable-bugs.math-min-identical-args.review
40+ @severity: warning
41+ "Math.min() with identical arguments — probably a copy-paste bug.":
3242java.lang.Math.min($a, $a)
3343;;
3444
35- // Hint-only: potential time overflow due to clock adjustments
36- "System.currentTimeMillis() may go backwards due to clock adjustments — consider System.nanoTime() for elapsed time":
45+ @id: probable-bugs.currenttimemillis-negative-elapsed.review
46+ @severity: warning
47+ "System.currentTimeMillis() may go backwards due to clock adjustments — consider System.nanoTime() for elapsed time.":
3748System.currentTimeMillis() - $start < 0
3849;;
39-
40- $x == $x :: !instanceof($x, "double") && !instanceof($x, "float")
41- => true
42- ;;
43-
44- @id: arrays.correctness.array-object-equals
45- @severity: error
46- !$array1.equals($array2) :: instanceof($array1, "java.lang.Object[]") && instanceof($array2, "java.lang.Object[]")
47- => !java.util.Arrays.equals($array1, $array2)
48- ;;
49-
50- @id: arrays.correctness.array-object-equals-positive
51- @severity: error
52- $array1.equals($array2) :: instanceof($array1, "java.lang.Object[]") && instanceof($array2, "java.lang.Object[]")
53- => java.util.Arrays.equals($array1, $array2)
54- ;;
0 commit comments