Java inspection: Rename the inspection "Replace Equality with Equals" to a noun-based...
authorPavel Dolgov <pavel.dolgov@jetbrains.com>
Mon, 8 Aug 2016 18:05:02 +0000 (21:05 +0300)
committerPavel Dolgov <pavel.dolgov@jetbrains.com>
Tue, 9 Aug 2016 09:02:45 +0000 (12:02 +0300)
plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/META-INF/InspectionGadgets.xml
plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/InspectionGadgetsBundle.properties
plugins/InspectionGadgets/src/com/siyeh/ig/equality/EqualityOperatorComparesObjectsInspection.java [moved from plugins/InspectionGadgets/src/com/siyeh/ig/equality/ReplaceEqualityWithEqualsInspection.java with 90% similarity]
plugins/InspectionGadgets/src/inspectionDescriptions/EqualityOperatorComparesObjects.html [new file with mode: 0644]
plugins/InspectionGadgets/src/inspectionDescriptions/ReplaceEqualityWithEquals.html [deleted file]
plugins/InspectionGadgets/testsrc/com/siyeh/ig/fixes/equality/EqualityOperatorComparesObjectsInspectionJdk6Test.java [moved from plugins/InspectionGadgets/testsrc/com/siyeh/ig/fixes/equality/ReplaceEqualityWithEqualsInspectionJdk6Test.java with 90% similarity]
plugins/InspectionGadgets/testsrc/com/siyeh/ig/fixes/equality/EqualityOperatorComparesObjectsInspectionJdk7Test.java [moved from plugins/InspectionGadgets/testsrc/com/siyeh/ig/fixes/equality/ReplaceEqualityWithEqualsInspectionJdk7Test.java with 90% similarity]
plugins/InspectionGadgets/testsrc/com/siyeh/ig/fixes/equality/EqualityOperatorComparesObjectsInspectionTestBase.java [moved from plugins/InspectionGadgets/testsrc/com/siyeh/ig/fixes/equality/ReplaceEqualityWithEqualsInspectionTestBase.java with 77% similarity]

index 0e65b30f0388b015d0d7bf2d8d2bb3393e3b3f27..7ee0e7f5993d7ba75c129ec3359f46f814e714f9 100644 (file)
                      key="if.can.be.assertion.name" groupBundle="messages.InspectionsBundle"
                      groupKey="group.names.control.flow.issues" enabledByDefault="true" level="INFORMATION"
                      implementationClass="com.siyeh.ig.asserttoif.IfCanBeAssertionInspection"/>
-    <localInspection groupPath="Java" language="JAVA" shortName="ReplaceEqualityWithEquals" bundle="com.siyeh.InspectionGadgetsBundle"
-                     key="replace.equality.with.equals.name" groupBundle="messages.InspectionsBundle"
+    <localInspection groupPath="Java" language="JAVA" shortName="EqualityOperatorComparesObjects" bundle="com.siyeh.InspectionGadgetsBundle"
+                     key="equality.operator.compares.objects.name" groupBundle="messages.InspectionsBundle"
                      groupKey="group.names.control.flow.issues" enabledByDefault="true" level="INFORMATION"
-                     implementationClass="com.siyeh.ig.equality.ReplaceEqualityWithEqualsInspection"/>
+                     implementationClass="com.siyeh.ig.equality.EqualityOperatorComparesObjectsInspection"/>
 
     <!--group.names.data.flow.issues-->
     <localInspection groupPath="Java" language="JAVA" shortName="BooleanVariableAlwaysNegated" bundle="com.siyeh.InspectionGadgetsBundle"
index e583cfab0abc22abbaeb25928f9f1922b41bce9d..e26a78e498465e7b647043d58cb3d98fa46f2413 100644 (file)
@@ -2174,10 +2174,12 @@ assertion.can.be.if.name=Assertion can be replaced with if statement
 assert.can.be.if.quickfix=Replace 'assert' with 'if' statement
 if.can.be.assertion.name=If statement can be replaced with assertion
 if.can.be.assertion.quickfix=Replace 'if' with 'assert' statement
-replace.equality.with.equals.name=Replace Equality with Equals
-replace.equality.with.equals.descriptor=Replace ''{0}'' with ''{1}equals()''
-replace.equality.with.safe.equals.name=Replace Equality with Safe Equals
-replace.equality.with.safe.equals.descriptor=Replace ''{0}'' with safe ''{1}equals()''
+equality.operator.compares.objects.name=Equality operator compares objects
+equality.operator.compares.objects.descriptor=Equality operator ''{0}'' compares objects
+equality.operator.compares.objects.quickfix=Replace ''{0}'' with ''{1}equals()''
+equality.operator.compares.objects.family.quickfix=Replace equality operator with equals()
+equality.operator.compares.objects.safe.quickfix=Replace ''{0}'' with safe ''{1}equals()''
+equality.operator.compares.objects.safe.family.quickfix=Replace equality operator with safe equals()
 single.statement.in.block.name=Code block contains single statement
 single.statement.in.block.descriptor=''{0}'' contains single statement
 single.statement.in.block.quickfix=Remove braces from ''{0}'' statement
similarity index 90%
rename from plugins/InspectionGadgets/src/com/siyeh/ig/equality/ReplaceEqualityWithEqualsInspection.java
rename to plugins/InspectionGadgets/src/com/siyeh/ig/equality/EqualityOperatorComparesObjectsInspection.java
index dd75ea696217d478697d7debe0bb7ccebc572dec..57d00fc9dcfbadd871713c1711344b3cacf647d3 100644 (file)
@@ -32,19 +32,19 @@ import org.jetbrains.annotations.Nls;
 import org.jetbrains.annotations.NonNls;
 import org.jetbrains.annotations.NotNull;
 
-public class ReplaceEqualityWithEqualsInspection extends BaseInspection {
+public class EqualityOperatorComparesObjectsInspection extends BaseInspection {
 
   @Nls
   @NotNull
   @Override
   public String getDisplayName() {
-    return InspectionGadgetsBundle.message("replace.equality.with.equals.name");
+    return InspectionGadgetsBundle.message("equality.operator.compares.objects.name");
   }
 
   @NotNull
   @Override
   protected String buildErrorString(Object... infos) {
-    return InspectionGadgetsBundle.message("replace.equality.with.equals.descriptor", infos);
+    return InspectionGadgetsBundle.message("equality.operator.compares.objects.descriptor", infos);
   }
 
   @Override
@@ -143,14 +143,14 @@ public class ReplaceEqualityWithEqualsInspection extends BaseInspection {
     @NotNull
     @Override
     public String getName() {
-      return InspectionGadgetsBundle.message("replace.equality.with.safe.equals.descriptor", myInfos);
+      return InspectionGadgetsBundle.message("equality.operator.compares.objects.safe.quickfix", myInfos);
     }
 
     @Nls
     @NotNull
     @Override
     public String getFamilyName() {
-      return InspectionGadgetsBundle.message("replace.equality.with.safe.equals.name");
+      return InspectionGadgetsBundle.message("equality.operator.compares.objects.safe.family.quickfix");
     }
 
     @Override
@@ -170,14 +170,14 @@ public class ReplaceEqualityWithEqualsInspection extends BaseInspection {
     @NotNull
     @Override
     public String getName() {
-      return InspectionGadgetsBundle.message("replace.equality.with.equals.descriptor", myInfos);
+      return InspectionGadgetsBundle.message("equality.operator.compares.objects.quickfix", myInfos);
     }
 
     @Nls
     @NotNull
     @Override
     public String getFamilyName() {
-      return InspectionGadgetsBundle.message("replace.equality.with.equals.name");
+      return InspectionGadgetsBundle.message("equality.operator.compares.objects.family.quickfix");
     }
 
     @Override
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/EqualityOperatorComparesObjects.html b/plugins/InspectionGadgets/src/inspectionDescriptions/EqualityOperatorComparesObjects.html
new file mode 100644 (file)
index 0000000..5263c25
--- /dev/null
@@ -0,0 +1,7 @@
+<html>
+<body>
+This inspection reports <b>==</b> and <b>!=</b> equality operators that compare two objects.
+<p>The quick fix offers to replace the equality operators with calls of the <b>.equals()</b> method
+  or with the safe <b>.equals()</b> method construct.
+</body>
+</html>
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/ReplaceEqualityWithEquals.html b/plugins/InspectionGadgets/src/inspectionDescriptions/ReplaceEqualityWithEquals.html
deleted file mode 100644 (file)
index 8798c46..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-<html>
-<body>
-This inspection reports <b>==</b> equality operators that compare two objects
-and offers to replace them with calls of the <b>.equals()</b> method or with the safe <b>.equals()</b> method construct.
-</body>
-</html>
@@ -22,7 +22,7 @@ import com.intellij.testFramework.builders.JavaModuleFixtureBuilder;
 /**
  * @author Pavel.Dolgov
  */
-public class ReplaceEqualityWithEqualsInspectionJdk6Test extends ReplaceEqualityWithEqualsInspectionTestBase {
+public class EqualityOperatorComparesObjectsInspectionJdk6Test extends EqualityOperatorComparesObjectsInspectionTestBase {
 
   public void testSimpleObjectOldSafeComparison() { doTest(true, true); }
   public void testNegatedObjectOldSafeComparison() { doTest(false, true); }
@@ -22,7 +22,7 @@ import com.intellij.testFramework.builders.JavaModuleFixtureBuilder;
 /**
  * @author Pavel.Dolgov
  */
-public class ReplaceEqualityWithEqualsInspectionJdk7Test extends ReplaceEqualityWithEqualsInspectionTestBase {
+public class EqualityOperatorComparesObjectsInspectionJdk7Test extends EqualityOperatorComparesObjectsInspectionTestBase {
 
   public void testSimpleObjectSafeComparison() { doTest(true, true); }
   public void testNegatedObjectSafeComparison() { doTest(false, true); }
@@ -17,13 +17,13 @@ package com.siyeh.ig.fixes.equality;
 
 import com.siyeh.InspectionGadgetsBundle;
 import com.siyeh.ig.IGQuickFixesTestCase;
-import com.siyeh.ig.equality.ReplaceEqualityWithEqualsInspection;
+import com.siyeh.ig.equality.EqualityOperatorComparesObjectsInspection;
 
 /**
- * @see ReplaceEqualityWithEqualsInspection
+ * @see EqualityOperatorComparesObjectsInspection
  * @author Bas Leijdekkers
  */
-public abstract class ReplaceEqualityWithEqualsInspectionTestBase extends IGQuickFixesTestCase {
+public abstract class EqualityOperatorComparesObjectsInspectionTestBase extends IGQuickFixesTestCase {
 
   public void testEnumComparison() { assertQuickfixNotAvailable(); }
   public void testNullComparison() { assertQuickfixNotAvailable(); }
@@ -34,14 +34,14 @@ public abstract class ReplaceEqualityWithEqualsInspectionTestBase extends IGQuic
   @Override
   protected void setUp() throws Exception {
     super.setUp();
-    myFixture.enableInspections(new ReplaceEqualityWithEqualsInspection());
+    myFixture.enableInspections(new EqualityOperatorComparesObjectsInspection());
     myDefaultHint = "Replace";
     myRelativePath = "equality/replace_equality_with_equals";
   }
 
   protected void doTest(boolean isEqual, boolean isSafe) {
     doTest(InspectionGadgetsBundle.message(
-      isSafe ? "replace.equality.with.safe.equals.descriptor" : "replace.equality.with.equals.descriptor",
+      isSafe ? "equality.operator.compares.objects.safe.quickfix" : "equality.operator.compares.objects.quickfix",
       isEqual ? "==" : "!=",
       isEqual ? "" : "!"));
   }