Bug 570592 - [AutoRefactor immigration #61/149] [cleanup & saveaction]
Comparison to zero
Change-Id: Ibc2aa457a89e6fd25ec79c55e17a8a3977b5e3bd
Signed-off-by: Fabrice Tiercelin <fabrice.tiercelin@yahoo.fr>
Depends-On: I87095f266fce7af9358798008d6f9edcb7bf50f3
diff --git a/4.19/images/comparison-zero-after.png b/4.19/images/comparison-zero-after.png
new file mode 100644
index 0000000..ea876cf
--- /dev/null
+++ b/4.19/images/comparison-zero-after.png
Binary files differ
diff --git a/4.19/images/comparison-zero-before.png b/4.19/images/comparison-zero-before.png
new file mode 100644
index 0000000..1bcca72
--- /dev/null
+++ b/4.19/images/comparison-zero-before.png
Binary files differ
diff --git a/4.19/jdt.html b/4.19/jdt.html
index 9707a89..800a651 100644
--- a/4.19/jdt.html
+++ b/4.19/jdt.html
@@ -406,6 +406,31 @@
</td>
</tr>
+ <tr id="comparison-zero"> <!-- https://bugs.eclipse.org/bugs/show_bug.cgi?id=570592 -->
+ <td class="title"><a href="#comparison-zero">Comparison to zero</a></td>
+ <td class="content">
+ A new clean up has been added that fixes <code>Comparable.compareTo()</code> usage.
+ <p>
+ The developer is not supposed to predict the <code>1</code> and <code>-1</code> values; them is supposed to get zero or a value lesser or greater than zero.
+ </p>
+ <p>
+ Beware! The behavior may change if you implement a custom comparator!
+ </p>
+ <p>
+ To apply the clean up, select <b>Compare to zero</b> check box on the <b>Source Fixing</b> tab in your clean up profile.
+ </p>
+ <p><img src="images/source-fixing-preferences.png" alt="Preferences" width="800 px"/></p>
+ <p>
+ For the given code:
+ </p>
+ <p><img src="images/comparison-zero-before.png" alt="Before"/></p>
+ <p>
+ One gets:
+ </p>
+ <p><img src="images/comparison-zero-after.png" alt="After"/></p>
+ </td>
+ </tr>
+
<tr id="restricted-identifier-preference"> <!-- https://bugs.eclipse.org/bugs/show_bug.cgi?id=569759 -->
<td class="title"><a href="#restricted-identifier-preference">Coloring restricted identifiers</a></td>
<td class="content">