summaryrefslogtreecommitdiff
path: root/plugins/InspectionGadgets/src
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/InspectionGadgets/src')
-rw-r--r--plugins/InspectionGadgets/src/com/siyeh/ig/junit/JUnit3MethodNamingConventionInspection.java30
-rw-r--r--plugins/InspectionGadgets/src/com/siyeh/ig/junit/JUnit4AnnotatedMethodInJUnit3TestCaseInspection.java31
-rw-r--r--plugins/InspectionGadgets/src/com/siyeh/ig/junit/JUnit4MethodNamingConventionInspection.java30
-rw-r--r--plugins/InspectionGadgets/src/inspectionDescriptions/EqualsWithItself.html10
-rw-r--r--plugins/InspectionGadgets/src/inspectionDescriptions/InstanceMethodNamingConvention.html2
-rw-r--r--plugins/InspectionGadgets/src/inspectionDescriptions/JUnit3MethodNamingConvention.html13
-rw-r--r--plugins/InspectionGadgets/src/inspectionDescriptions/JUnit4MethodNamingConvention.html13
-rw-r--r--plugins/InspectionGadgets/src/inspectionDescriptions/NativeMethodNamingConvention.html6
-rw-r--r--plugins/InspectionGadgets/src/inspectionDescriptions/StaticMethodNamingConvention.html2
-rw-r--r--plugins/InspectionGadgets/src/inspectionDescriptions/TestMethodIsPublicVoidNoArg.html4
10 files changed, 128 insertions, 13 deletions
diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/junit/JUnit3MethodNamingConventionInspection.java b/plugins/InspectionGadgets/src/com/siyeh/ig/junit/JUnit3MethodNamingConventionInspection.java
new file mode 100644
index 000000000000..29dcf0bf1a01
--- /dev/null
+++ b/plugins/InspectionGadgets/src/com/siyeh/ig/junit/JUnit3MethodNamingConventionInspection.java
@@ -0,0 +1,30 @@
+/*
+ * Copyright 2000-2014 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.siyeh.ig.junit;
+
+import com.siyeh.ig.InspectionGadgetsFix;
+import com.siyeh.ig.fixes.RenameFix;
+
+/**
+ * @author Bas Leijdekkers
+ */
+public class JUnit3MethodNamingConventionInspection extends JUnit3MethodNamingConventionInspectionBase {
+
+ @Override
+ protected InspectionGadgetsFix buildFix(Object... infos) {
+ return new RenameFix();
+ }
+}
diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/junit/JUnit4AnnotatedMethodInJUnit3TestCaseInspection.java b/plugins/InspectionGadgets/src/com/siyeh/ig/junit/JUnit4AnnotatedMethodInJUnit3TestCaseInspection.java
index 252411527cc1..89ad944a0f78 100644
--- a/plugins/InspectionGadgets/src/com/siyeh/ig/junit/JUnit4AnnotatedMethodInJUnit3TestCaseInspection.java
+++ b/plugins/InspectionGadgets/src/com/siyeh/ig/junit/JUnit4AnnotatedMethodInJUnit3TestCaseInspection.java
@@ -18,6 +18,7 @@ package com.siyeh.ig.junit;
import com.intellij.codeInsight.AnnotationUtil;
import com.intellij.codeInspection.ProblemDescriptor;
import com.intellij.openapi.project.Project;
+import com.intellij.openapi.util.text.StringUtil;
import com.intellij.psi.*;
import com.intellij.psi.codeStyle.JavaCodeStyleManager;
import com.siyeh.InspectionGadgetsBundle;
@@ -41,7 +42,16 @@ public class JUnit4AnnotatedMethodInJUnit3TestCaseInspection extends JUnit4Annot
fixes.add(new RemoveIgnoreAndRename(method));
}
if (TestUtils.isJUnit4TestMethod(method)) {
- fixes.add(new RemoveTestAnnotationFix());
+ String methodName = method.getName();
+ String newMethodName;
+ if (methodName.startsWith("test")) {
+ newMethodName = null;
+ }
+ else {
+ boolean lowCaseStyle = methodName.contains("_");
+ newMethodName = "test" + (lowCaseStyle ? "_" + methodName : StringUtil.capitalize(methodName));
+ }
+ fixes.add(new RemoveTestAnnotationFix(newMethodName));
}
final PsiClass aClass = (PsiClass)infos[0];
final String className = aClass.getName();
@@ -233,22 +243,33 @@ public class JUnit4AnnotatedMethodInJUnit3TestCaseInspection extends JUnit4Annot
}
}
- private static class RemoveTestAnnotationFix extends InspectionGadgetsFix {
+ private static class RemoveTestAnnotationFix extends RenameFix {
+ private final String myNewName;
+
+ public RemoveTestAnnotationFix(String newName) {
+ super(newName);
+ myNewName = newName;
+ }
+
@Override
@NotNull
public String getFamilyName() {
- return getName();
+ return InspectionGadgetsBundle.message("remove.junit4.test.annotation.quickfix");
}
@Override
@NotNull
public String getName() {
- return InspectionGadgetsBundle.message("remove.junit4.test.annotation.quickfix");
+ return myNewName == null ? getFamilyName()
+ : InspectionGadgetsBundle.message("remove.junit4.test.annotation.and.rename.quickfix", myNewName);
}
@Override
- protected void doFix(Project project, ProblemDescriptor descriptor) {
+ public void doFix(Project project, ProblemDescriptor descriptor) {
deleteAnnotation(descriptor, "org.junit.Test");
+ if (myNewName != null) {
+ super.doFix(project, descriptor);
+ }
}
}
}
diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/junit/JUnit4MethodNamingConventionInspection.java b/plugins/InspectionGadgets/src/com/siyeh/ig/junit/JUnit4MethodNamingConventionInspection.java
new file mode 100644
index 000000000000..22c8937d48d9
--- /dev/null
+++ b/plugins/InspectionGadgets/src/com/siyeh/ig/junit/JUnit4MethodNamingConventionInspection.java
@@ -0,0 +1,30 @@
+/*
+ * Copyright 2000-2014 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.siyeh.ig.junit;
+
+import com.siyeh.ig.InspectionGadgetsFix;
+import com.siyeh.ig.fixes.RenameFix;
+
+/**
+ * @author Bas Leijdekkers
+ */
+public class JUnit4MethodNamingConventionInspection extends JUnit4MethodNamingConventionInspectionBase {
+
+ @Override
+ protected InspectionGadgetsFix buildFix(Object... infos) {
+ return new RenameFix();
+ }
+}
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/EqualsWithItself.html b/plugins/InspectionGadgets/src/inspectionDescriptions/EqualsWithItself.html
new file mode 100644
index 000000000000..3e1491edd22e
--- /dev/null
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/EqualsWithItself.html
@@ -0,0 +1,10 @@
+<html>
+<body>
+Reports call to <b>equals()</b> were an object is compared for equality with itself.
+This means that the argument and the qualifier to the call are identical.
+In this case <b>equals()</b> will always return <b>true</b>.
+<!-- tooltip end -->
+<p>
+<small>New in 14</small>
+</body>
+</html> \ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/InstanceMethodNamingConvention.html b/plugins/InspectionGadgets/src/inspectionDescriptions/InstanceMethodNamingConvention.html
index a6933cf0c7b8..4bf1c67710c5 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/InstanceMethodNamingConvention.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/InstanceMethodNamingConvention.html
@@ -8,8 +8,6 @@ methods are ignored by this inspection.
Use the fields below to specify minimum length, maximum length and regular expression expected for instance method names.
Specify <b>0</b> to not check the length of names. Regular expressions are in standard <b>java.util.regex</b> format.
<p>
-Use the checkbox below to ignore native methods.
-<p>
</body>
</html> \ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/JUnit3MethodNamingConvention.html b/plugins/InspectionGadgets/src/inspectionDescriptions/JUnit3MethodNamingConvention.html
new file mode 100644
index 000000000000..253c7297cdcc
--- /dev/null
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/JUnit3MethodNamingConvention.html
@@ -0,0 +1,13 @@
+<html>
+<body>
+Reports JUnit 3 test methods whose names are either too short, too long, or do not follow the specified regular expression pattern.
+When this inspection is enabled, the <i>Instance method naming convention</i> inspection
+will ignore JUnit 3 test methods automatically.
+<!-- tooltip end -->
+<p>
+Use the fields below to specify minimum length, maximum length and regular expression expected for JUnit 3 test method names.
+Specify <b>0</b> to not check the length of names. Regular expressions are in standard <b>java.util.regex</b> format.
+<p>
+<small>New in 14</small>
+</body>
+</html> \ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/JUnit4MethodNamingConvention.html b/plugins/InspectionGadgets/src/inspectionDescriptions/JUnit4MethodNamingConvention.html
new file mode 100644
index 000000000000..a53cc8817015
--- /dev/null
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/JUnit4MethodNamingConvention.html
@@ -0,0 +1,13 @@
+<html>
+<body>
+Reports JUnit 4 test methods whose names are either too short, too long, or do not follow the specified regular expression pattern.
+When this inspection is enabled, the <i>Instance method naming convention</i> inspection
+will ignore JUnit 4 test methods automatically.
+<!-- tooltip end -->
+<p>
+Use the fields below to specify minimum length, maximum length and regular expression expected for JUnit 4 test method names.
+Specify <b>0</b> to not check the length of names. Regular expressions are in standard <b>java.util.regex</b> format.
+<p>
+<small>New in 14</small>
+</body>
+</html> \ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/NativeMethodNamingConvention.html b/plugins/InspectionGadgets/src/inspectionDescriptions/NativeMethodNamingConvention.html
index c2e866b3d223..2ffd3a2a27a3 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/NativeMethodNamingConvention.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/NativeMethodNamingConvention.html
@@ -1,11 +1,13 @@
<html>
<body>
-Reports 'native' methods whose names are either too short, too long, or do not follow
+Reports <b>native</b> methods whose names are either too short, too long, or do not follow
the specified regular expression pattern. Methods that override library
methods are ignored by this inspection.
+When this inspection is enabled, the <i>Instance method naming convention</i> and
+<i>'static' method naming convention</i> inspections will ignore <b>native</b> methods automatically.
<!-- tooltip end -->
<p>
-Use the fields below to specify minimum length, maximum length and regular expression expected for 'native' method names.
+Use the fields below to specify minimum length, maximum length and regular expression expected for <b>native</b> method names.
Specify <b>0</b> to not check the length of names. Regular expressions are in standard <b>java.util.regex</b> format.
<p>
<small>New in 14</small>
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/StaticMethodNamingConvention.html b/plugins/InspectionGadgets/src/inspectionDescriptions/StaticMethodNamingConvention.html
index 37d12a6af08d..c0ced0ba01bd 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/StaticMethodNamingConvention.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/StaticMethodNamingConvention.html
@@ -7,8 +7,6 @@ the specified regular expression pattern.
Use the fields below to specify minimum length, maximum length and regular expression expected for static method names.
Specify <b>0</b> to not check the length of names. Regular expressions are in standard <b>java.util.regex</b> format.
<p>
-Use the checkbox below to ignore native methods.
-<p>
</body>
</html> \ No newline at end of file
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/TestMethodIsPublicVoidNoArg.html b/plugins/InspectionGadgets/src/inspectionDescriptions/TestMethodIsPublicVoidNoArg.html
index a31b39a1a710..fe227cae1fbc 100644
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/TestMethodIsPublicVoidNoArg.html
+++ b/plugins/InspectionGadgets/src/inspectionDescriptions/TestMethodIsPublicVoidNoArg.html
@@ -1,8 +1,8 @@
<html>
<body>
-Reports any JUnit test methods whose names which are not declared
+Reports any JUnit test methods which are declared <b>static</b>, not declared
<b>public</b>, do not return
-<b>void</b>, or take arguments.
+<b>void</b>, or have parameters.
Such test methods are easy to create inadvertently, but will not be executed by
JUnit test runners.
<!-- tooltip end -->