#ref() has no logging call #loc
-finalize.doesnt.call.super.display.name='finalize()' does not call 'super.finalize()'
-finalize.doesnt.call.super.ignore.option=Ignore for direct subclasses of 'java.lang.Object'
ignore.trivial.finalizers.option=Ignore for trivial 'finalize()' implementations
-finalize.doesnt.call.super.problem.descriptor=#ref() #loc does not call 'super.finalize()'
finalize.declaration.display.name='finalize()' declaration
finalize.declaration.problem.descriptor=#ref() declared #loc
finalize.not.declared.protected.display.name='finalize()' not declared 'protected'
@@ -220,8 +217,6 @@ unused.import.display.name=Unused import
unused.import.problem.descriptor=Unused import #ref #loc
clone.instantiates.objects.with.constructor.display.name='clone()' instantiates objects with constructor
clone.instantiates.objects.with.constructor.problem.descriptor='clone()' creates new #ref instances #loc
-clone.doesnt.call.super.clone.display.name='clone()' does not call 'super.clone()'
-clone.doesnt.call.super.clone.problem.descriptor=#ref() does not call 'super.clone()' #loc
clone.doesnt.declare.clonenotsupportedexception.display.name='clone()' does not declare 'CloneNotSupportedException'
clone.doesnt.declare.clonenotsupportedexception.problem.descriptor=#ref() #loc does not declare 'CloneNotSupportedException'
clone.doesnt.declare.clonenotsupportedexception.declare.quickfix=Declare 'CloneNotSupportedException'
@@ -662,7 +657,6 @@ parameter.name.differs.from.overridden.parameter.display.name=Parameter name dif
final.private.method.display.name='private' method declared 'final'
enum.switch.statement.which.misses.cases.display.name=Enum 'switch' statement that misses case
enum.switch.statement.which.misses.cases.option=Ignore switch statements with a default branch
-setup.calls.super.setup.display.name='setUp()' does not call 'super.setUp()'
unconstructable.test.case.display.name=Unconstructable JUnit TestCase
volatile.long.or.double.field.display.name=Volatile long or double field
string.buffer.must.have.initial.capacity.display.name=StringBuffer or StringBuilder without initial capacity
@@ -789,7 +783,6 @@ three.negations.per.method.display.name=Method with more than three negations
conditional.expression.display.name=Conditional expression (?:)
unnecessary.enum.modifier.display.name=Unnecessary enum modifier
string.equals.empty.string.display.name='String.equals("")'
-teardown.calls.super.teardown.display.name='tearDown()' does not call 'super.tearDown()'
synchronize.on.lock.display.name=Synchronization on a Lock object
synchronized.on.literal.object.name=Synchronization on an object initialized with a literal
field.may.be.static.display.name=Field may be 'static'
@@ -1074,8 +1067,6 @@ test.case.with.constructor.problem.descriptor=Initialization logic in constructo
test.case.with.constructor.problem.descriptor.initializer=Initialization logic in initializer instead of 'setUp()'
misordered.assert.equals.arguments.problem.descriptor=Arguments to #ref() in wrong order #loc
static.suite.problem.descriptor=JUnit #ref() methods not declared 'static' #loc
-setup.calls.super.setup.problem.descriptor=#ref() does not call 'super.setUp()' #loc
-teardown.calls.super.teardown.problem.descriptor=#ref() does not call 'super.tearDown()' #loc
simplifiable.junit.assertion.problem.descriptor=#ref() can be simplified to ''{0}'' #loc
test.method.without.assertion.problem.descriptor=JUnit test method #ref() contains no assertions #loc
test.case.with.no.test.methods.problem.descriptor=JUnit test case #ref has no tests #loc
@@ -1155,9 +1146,7 @@ foreach.replace.quickfix=Replace with 'foreach'
unnecessary.boxing.remove.quickfix=Remove boxing
unnecessary.unboxing.remove.quickfix=Remove unboxing
misordered.assert.equals.arguments.flip.quickfix=Flip compared arguments
-setup.calls.super.setup.add.quickfix=Add call to 'super.setUp()'
simplify.junit.assertion.simplify.quickfix=Simplify assertion
-teardown.calls.super.teardown.add.quickfix=Add call to 'super.tearDown()'
test.method.is.public.void.no.arg.problem.descriptor1=Test method #ref() should probably not have parameters #loc
test.method.is.public.void.no.arg.problem.descriptor2=Test method #ref() is not declared 'public void' #loc
test.method.is.public.void.no.arg.problem.descriptor3=Test method #ref() should not be 'static' #loc
diff --git a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/cloneable/CloneCallsSuperCloneInspection.java b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/cloneable/CloneCallsSuperCloneInspection.java
deleted file mode 100644
index b45add57d943..000000000000
--- a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/cloneable/CloneCallsSuperCloneInspection.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Copyright 2003-2016 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.
- * 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.cloneable;
-
-import com.intellij.psi.PsiClass;
-import com.intellij.psi.PsiMethod;
-import com.intellij.psi.PsiModifier;
-import com.siyeh.HardcodedMethodConstants;
-import com.siyeh.InspectionGadgetsBundle;
-import com.siyeh.ig.BaseInspection;
-import com.siyeh.ig.BaseInspectionVisitor;
-import com.siyeh.ig.psiutils.CloneUtils;
-import com.siyeh.ig.psiutils.MethodCallUtils;
-import org.jetbrains.annotations.NotNull;
-
-public class CloneCallsSuperCloneInspection extends BaseInspection {
-
- @Override
- @NotNull
- public String getID() {
- return "CloneDoesntCallSuperClone";
- }
-
- @Override
- @NotNull
- public String getDisplayName() {
- return InspectionGadgetsBundle.message(
- "clone.doesnt.call.super.clone.display.name");
- }
-
- @Override
- @NotNull
- public String buildErrorString(Object... infos) {
- return InspectionGadgetsBundle.message(
- "clone.doesnt.call.super.clone.problem.descriptor");
- }
-
- @Override
- public boolean isEnabledByDefault() {
- return true;
- }
-
- @Override
- public BaseInspectionVisitor buildVisitor() {
- return new NoExplicitCloneCallsVisitor();
- }
-
- private static class NoExplicitCloneCallsVisitor
- extends BaseInspectionVisitor {
-
- @Override
- public void visitMethod(@NotNull PsiMethod method) {
- //note: no call to super;
- if (!CloneUtils.isClone(method)) {
- return;
- }
- if (method.hasModifierProperty(PsiModifier.ABSTRACT) ||
- method.hasModifierProperty(PsiModifier.NATIVE)) {
- return;
- }
- final PsiClass containingClass = method.getContainingClass();
- if (containingClass == null) {
- return;
- }
- if (containingClass.isInterface() ||
- containingClass.isAnnotationType()) {
- return;
- }
- if (CloneUtils.onlyThrowsException(method)) {
- return;
- }
- if (MethodCallUtils.containsSuperMethodCall(method)) {
- return;
- }
- registerMethodError(method);
- }
- }
-}
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/finalization/FinalizeCallsSuperFinalizeInspection.java b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/finalization/FinalizeCallsSuperFinalizeInspection.java
deleted file mode 100644
index 4a7c075fca50..000000000000
--- a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/finalization/FinalizeCallsSuperFinalizeInspection.java
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- * 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.
- * 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.finalization;
-
-import com.intellij.codeInspection.ui.MultipleCheckboxOptionsPanel;
-import com.intellij.psi.*;
-import com.siyeh.HardcodedMethodConstants;
-import com.siyeh.InspectionGadgetsBundle;
-import com.siyeh.ig.BaseInspection;
-import com.siyeh.ig.BaseInspectionVisitor;
-import com.siyeh.ig.psiutils.MethodCallUtils;
-import com.siyeh.ig.psiutils.MethodUtils;
-import org.jetbrains.annotations.NotNull;
-
-import javax.swing.*;
-
-public class FinalizeCallsSuperFinalizeInspection extends BaseInspection {
-
- @SuppressWarnings("PublicField")
- public boolean ignoreObjectSubclasses = false;
-
- @SuppressWarnings("PublicField")
- public boolean ignoreTrivialFinalizers = true;
-
- @Override
- @NotNull
- public String getID() {
- return "FinalizeDoesntCallSuperFinalize";
- }
-
- @Override
- @NotNull
- public String getDisplayName() {
- return InspectionGadgetsBundle.message(
- "finalize.doesnt.call.super.display.name");
- }
-
- @Override
- @NotNull
- public String buildErrorString(Object... infos) {
- return InspectionGadgetsBundle.message(
- "finalize.doesnt.call.super.problem.descriptor");
- }
-
- @Override
- public boolean isEnabledByDefault() {
- return true;
- }
-
- @Override
- public JComponent createOptionsPanel() {
- final MultipleCheckboxOptionsPanel optionsPanel =
- new MultipleCheckboxOptionsPanel(this);
- optionsPanel.addCheckbox(InspectionGadgetsBundle.message(
- "finalize.doesnt.call.super.ignore.option"),
- "ignoreObjectSubclasses");
- optionsPanel.addCheckbox(InspectionGadgetsBundle.message(
- "ignore.trivial.finalizers.option"),
- "ignoreTrivialFinalizers");
- return optionsPanel;
- }
-
- @Override
- public BaseInspectionVisitor buildVisitor() {
- return new NoExplicitFinalizeCallsVisitor();
- }
-
- private class NoExplicitFinalizeCallsVisitor extends BaseInspectionVisitor {
-
- @Override
- public void visitMethod(@NotNull PsiMethod method) {
- //note: no call to super;
- final String methodName = method.getName();
- if (!HardcodedMethodConstants.FINALIZE.equals(methodName)) {
- return;
- }
- if (method.hasModifierProperty(PsiModifier.NATIVE) ||
- method.hasModifierProperty(PsiModifier.ABSTRACT)) {
- return;
- }
- final PsiClass containingClass = method.getContainingClass();
- if (containingClass == null) {
- return;
- }
- if (ignoreObjectSubclasses) {
- final PsiClass superClass = containingClass.getSuperClass();
- if (superClass != null) {
- final String superClassName = superClass.getQualifiedName();
- if (CommonClassNames.JAVA_LANG_OBJECT.equals(superClassName)) {
- return;
- }
- }
- }
- final PsiParameterList parameterList = method.getParameterList();
- if (parameterList.getParametersCount() != 0) {
- return;
- }
- if (MethodCallUtils.containsSuperMethodCall(method)) {
- return;
- }
- if (ignoreTrivialFinalizers && MethodUtils.isTrivial(method, false)) {
- return;
- }
- registerMethodError(method);
- }
- }
-}
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/inheritance/MethodDoesntCallSuperMethodInspectionMerger.java b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/inheritance/MethodDoesntCallSuperMethodInspectionMerger.java
new file mode 100644
index 000000000000..b5db593406b3
--- /dev/null
+++ b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/inheritance/MethodDoesntCallSuperMethodInspectionMerger.java
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2000-2016 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.inheritance;
+
+import com.intellij.codeInspection.ex.InspectionElementsMerger;
+
+/**
+ * @author Bas Leijdekkers
+ */
+public class MethodDoesntCallSuperMethodInspectionMerger extends InspectionElementsMerger {
+
+ @Override
+ public String getMergedToolName() {
+ return "RefusedBequest";
+ }
+
+ @Override
+ public String[] getSourceToolNames() {
+ return new String[] {
+ "RefusedBequest",
+ "CloneCallsSuperClone",
+ "SetupCallsSuperSetUp",
+ "TeardownCallsSuperTearDown",
+ "FinalizeCallsSuperFinalize"
+ };
+ }
+
+ @Override
+ public String[] getSuppressIds() {
+ return new String[] {
+ "CloneDoesntCallSuperClone",
+ "SetUpDoesntCallSuperSetUp",
+ "TearDownDoesntCallSuperTearDown",
+ "FinalizeDoesntCallSuperFinalize"};
+ }
+}
diff --git a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/inheritance/RefusedBequestInspectionBase.java b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/inheritance/RefusedBequestInspectionBase.java
index 983105274e5f..f8df34c14563 100644
--- a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/inheritance/RefusedBequestInspectionBase.java
+++ b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/inheritance/RefusedBequestInspectionBase.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2003-2015 Dave Griffith, Bas Leijdekkers
+ * Copyright 2003-2016 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.
@@ -19,10 +19,13 @@ import com.intellij.codeInsight.AnnotationUtil;
import com.intellij.openapi.util.InvalidDataException;
import com.intellij.openapi.util.WriteExternalException;
import com.intellij.psi.*;
+import com.intellij.psi.util.InheritanceUtil;
+import com.siyeh.HardcodedMethodConstants;
import com.siyeh.InspectionGadgetsBundle;
import com.siyeh.ig.BaseInspection;
import com.siyeh.ig.BaseInspectionVisitor;
-import com.siyeh.ig.psiutils.ClassUtils;
+import com.siyeh.ig.psiutils.CloneUtils;
+import com.siyeh.ig.psiutils.MethodCallUtils;
import com.siyeh.ig.psiutils.MethodUtils;
import com.siyeh.ig.ui.ExternalizableStringSet;
import org.jdom.Element;
@@ -38,6 +41,12 @@ public class RefusedBequestInspectionBase extends BaseInspection {
@SuppressWarnings("PublicField") boolean onlyReportWhenAnnotated = true;
+ @Override
+ @NotNull
+ public String getID() {
+ return "MethodDoesntCallSuperMethod";
+ }
+
@Override
public void writeSettings(@NotNull Element node) throws WriteExternalException {
super.writeSettings(node);
@@ -103,10 +112,15 @@ public class RefusedBequestInspectionBase extends BaseInspection {
if (leastConcreteSuperMethod == null) {
return;
}
- final PsiClass objectClass = ClassUtils.findObjectClass(method);
- final PsiMethod[] superMethods = method.findSuperMethods(objectClass);
- if (superMethods.length > 0) {
- return;
+ final String methodName = method.getName();
+ if (!HardcodedMethodConstants.CLONE.equals(methodName)) {
+ final PsiClass superClass = leastConcreteSuperMethod.getContainingClass();
+ if (superClass != null) {
+ final String superClassName = superClass.getQualifiedName();
+ if (CommonClassNames.JAVA_LANG_OBJECT.equals(superClassName)) {
+ return;
+ }
+ }
}
if (ignoreEmptySuperMethods) {
final PsiElement element = leastConcreteSuperMethod.getNavigationElement();
@@ -115,17 +129,34 @@ public class RefusedBequestInspectionBase extends BaseInspection {
return;
}
}
- if (onlyReportWhenAnnotated) {
+ if (onlyReportWhenAnnotated && !CloneUtils.isClone(method) && !isJUnitSetUpOrTearDown(method)) {
if (!AnnotationUtil.isAnnotated(leastConcreteSuperMethod, annotations)) {
return;
}
}
- if (containsSuperCall(body, leastConcreteSuperMethod)) {
+ final PsiClass aClass = method.getContainingClass();
+ if ((aClass != null && aClass.hasModifierProperty(PsiModifier.FINAL) || method.hasModifierProperty(PsiModifier.FINAL)) &&
+ MethodUtils.isTrivial(method, true)) {
+ return;
+ }
+ if (MethodCallUtils.containsSuperMethodCall(method)) {
return;
}
registerMethodError(method);
}
+ private boolean isJUnitSetUpOrTearDown(PsiMethod method) {
+ final String name = method.getName();
+ if (!"setUp".equals(name) && !"tearDown".equals(name)) {
+ return false;
+ }
+ if (method.getParameterList().getParametersCount() != 0) {
+ return false;
+ }
+ final PsiClass aClass = method.getContainingClass();
+ return InheritanceUtil.isInheritor(aClass, "junit.framework.TestCase");
+ }
+
@Nullable
private PsiMethod getDirectSuperMethod(PsiMethod method) {
final PsiMethod superMethod = MethodUtils.getSuper(method);
@@ -138,58 +169,5 @@ public class RefusedBequestInspectionBase extends BaseInspection {
}
return superMethod;
}
-
- private boolean containsSuperCall(@NotNull PsiElement context, @NotNull PsiMethod method) {
- final SuperCallVisitor visitor = new SuperCallVisitor(method);
- context.accept(visitor);
- return visitor.hasSuperCall();
- }
- }
-
- private static class SuperCallVisitor extends JavaRecursiveElementWalkingVisitor {
-
- private final PsiMethod methodToSearchFor;
- private boolean hasSuperCall;
-
- SuperCallVisitor(PsiMethod methodToSearchFor) {
- this.methodToSearchFor = methodToSearchFor;
- }
-
- @Override
- public void visitElement(@NotNull PsiElement element) {
- if (hasSuperCall) {
- return;
- }
- super.visitElement(element);
- }
-
- @Override
- public void visitMethodCallExpression(
- @NotNull PsiMethodCallExpression expression) {
- if (hasSuperCall) {
- return;
- }
- super.visitMethodCallExpression(expression);
- final PsiReferenceExpression methodExpression = expression.getMethodExpression();
- final PsiExpression qualifier = methodExpression.getQualifierExpression();
- if (qualifier == null) {
- return;
- }
- final String text = qualifier.getText();
- if (!PsiKeyword.SUPER.equals(text)) {
- return;
- }
- final PsiMethod method = expression.resolveMethod();
- if (method == null) {
- return;
- }
- if (method.equals(methodToSearchFor)) {
- hasSuperCall = true;
- }
- }
-
- boolean hasSuperCall() {
- return hasSuperCall;
- }
}
}
diff --git a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/junit/SetupCallsSuperSetupInspection.java b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/junit/SetupCallsSuperSetupInspection.java
deleted file mode 100644
index e9d9462cbc98..000000000000
--- a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/junit/SetupCallsSuperSetupInspection.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * 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.
- * 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.intellij.codeInspection.ProblemDescriptor;
-import com.intellij.openapi.project.Project;
-import com.intellij.psi.*;
-import com.intellij.psi.codeStyle.CodeStyleManager;
-import com.intellij.util.IncorrectOperationException;
-import com.siyeh.InspectionGadgetsBundle;
-import com.siyeh.ig.BaseInspection;
-import com.siyeh.ig.BaseInspectionVisitor;
-import com.siyeh.ig.InspectionGadgetsFix;
-import org.jetbrains.annotations.NotNull;
-
-public class SetupCallsSuperSetupInspection extends BaseInspection {
-
- @Override
- @NotNull
- public String getID() {
- return "SetUpDoesntCallSuperSetUp";
- }
-
- @Override
- @NotNull
- public String getDisplayName() {
- return InspectionGadgetsBundle.message(
- "setup.calls.super.setup.display.name");
- }
-
- @Override
- @NotNull
- protected String buildErrorString(Object... infos) {
- return InspectionGadgetsBundle.message(
- "setup.calls.super.setup.problem.descriptor");
- }
-
- private static class AddSuperSetUpCall extends InspectionGadgetsFix {
- @Override
- @NotNull
- public String getFamilyName() {
- return getName();
- }
-
- @Override
- @NotNull
- public String getName() {
- return InspectionGadgetsBundle.message(
- "setup.calls.super.setup.add.quickfix");
- }
-
- @Override
- public void doFix(Project project, ProblemDescriptor descriptor)
- throws IncorrectOperationException {
- final PsiElement methodName = descriptor.getPsiElement();
- final PsiMethod method = (PsiMethod)methodName.getParent();
- assert method != null;
- final PsiCodeBlock body = method.getBody();
- if (body == null) {
- return;
- }
- final PsiElementFactory factory =
- JavaPsiFacade.getElementFactory(project);
- final PsiStatement newStatement =
- factory.createStatementFromText("super.setUp();", null);
- final CodeStyleManager styleManager =
- CodeStyleManager.getInstance(project);
- final PsiJavaToken brace = body.getLBrace();
- body.addAfter(newStatement, brace);
- styleManager.reformat(body);
- }
- }
-
- @Override
- protected InspectionGadgetsFix buildFix(Object... infos) {
- return new AddSuperSetUpCall();
- }
-
- @Override
- public BaseInspectionVisitor buildVisitor() {
- return new TeardownCallsSuperTeardownInspection.TeardownCallsSuperTeardownVisitor("setUp");
- }
-}
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/junit/TeardownCallsSuperTeardownInspection.java b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/junit/TeardownCallsSuperTeardownInspection.java
deleted file mode 100644
index cc6df8f621a9..000000000000
--- a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/junit/TeardownCallsSuperTeardownInspection.java
+++ /dev/null
@@ -1,140 +0,0 @@
-/*
- * Copyright 2003-2016 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.
- * 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.intellij.codeInspection.ProblemDescriptor;
-import com.intellij.openapi.project.Project;
-import com.intellij.psi.*;
-import com.intellij.psi.codeStyle.CodeStyleManager;
-import com.intellij.psi.util.InheritanceUtil;
-import com.intellij.util.IncorrectOperationException;
-import com.siyeh.InspectionGadgetsBundle;
-import com.siyeh.ig.BaseInspection;
-import com.siyeh.ig.BaseInspectionVisitor;
-import com.siyeh.ig.InspectionGadgetsFix;
-import com.siyeh.ig.psiutils.MethodCallUtils;
-import org.jetbrains.annotations.NonNls;
-import org.jetbrains.annotations.NotNull;
-
-public class TeardownCallsSuperTeardownInspection extends BaseInspection {
-
- @Override
- @NotNull
- public String getID() {
- return "TearDownDoesntCallSuperTearDown";
- }
-
- @Override
- @NotNull
- public String getDisplayName() {
- return InspectionGadgetsBundle.message(
- "teardown.calls.super.teardown.display.name");
- }
-
- @Override
- @NotNull
- protected String buildErrorString(Object... infos) {
- return InspectionGadgetsBundle.message(
- "teardown.calls.super.teardown.problem.descriptor");
- }
-
- @Override
- protected InspectionGadgetsFix buildFix(Object... infos) {
- return new AddSuperTearDownCall();
- }
-
- private static class AddSuperTearDownCall extends InspectionGadgetsFix {
-
- @Override
- @NotNull
- public String getName() {
- return InspectionGadgetsBundle.message(
- "teardown.calls.super.teardown.add.quickfix");
- }
- @Override
- @NotNull
- public String getFamilyName() {
- return getName();
- }
-
- @Override
- public void doFix(Project project, ProblemDescriptor descriptor)
- throws IncorrectOperationException {
- final PsiElement methodName = descriptor.getPsiElement();
- final PsiMethod method = (PsiMethod)methodName.getParent();
- if (method == null) {
- return;
- }
- final PsiCodeBlock body = method.getBody();
- if (body == null) {
- return;
- }
- final PsiElementFactory factory =
- JavaPsiFacade.getElementFactory(project);
- final PsiStatement newStatement =
- factory.createStatementFromText("super.tearDown();", null);
- final CodeStyleManager styleManager =
- CodeStyleManager.getInstance(project);
- final PsiJavaToken brace = body.getRBrace();
- body.addBefore(newStatement, brace);
- styleManager.reformat(body);
- }
- }
-
- @Override
- public BaseInspectionVisitor buildVisitor() {
- return new TeardownCallsSuperTeardownVisitor("tearDown");
- }
-
- public static class TeardownCallsSuperTeardownVisitor extends BaseInspectionVisitor {
-
- private final String myMethodName;
-
- public TeardownCallsSuperTeardownVisitor(String methodName) {
- myMethodName = methodName;
- }
-
- @Override
- public void visitMethod(@NotNull PsiMethod method) {
- //note: no call to super;
- @NonNls final String methodName = method.getName();
- if (!myMethodName.equals(methodName)) {
- return;
- }
- if (method.hasModifierProperty(PsiModifier.ABSTRACT)) {
- return;
- }
- if (method.getBody() == null) {
- return;
- }
- final PsiParameterList parameterList = method.getParameterList();
- if (parameterList.getParametersCount() != 0) {
- return;
- }
- final PsiClass targetClass = method.getContainingClass();
- if (targetClass == null) {
- return;
- }
- if (!InheritanceUtil.isInheritor(targetClass, "junit.framework.TestCase")) {
- return;
- }
- if (MethodCallUtils.containsSuperMethodCall(method)) {
- return;
- }
- registerMethodError(method);
- }
- }
-}
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/psiutils/MethodUtils.java b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/psiutils/MethodUtils.java
index bd80cb8df8ea..0d68882cceff 100644
--- a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/psiutils/MethodUtils.java
+++ b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/psiutils/MethodUtils.java
@@ -244,6 +244,9 @@ public class MethodUtils {
* also when it is a constructor which only calls super, contains empty statements or "if (false)" statements.
*/
public static boolean isTrivial(PsiMethod method, boolean throwIsTrivial) {
+ if (method.hasModifierProperty(PsiModifier.NATIVE)) {
+ return false;
+ }
return isTrivial(method.getBody(), throwIsTrivial);
}
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/CloneCallsSuperClone.html b/plugins/InspectionGadgets/src/inspectionDescriptions/CloneCallsSuperClone.html
deleted file mode 100644
index 2f013e8c67e6..000000000000
--- a/plugins/InspectionGadgets/src/inspectionDescriptions/CloneCallsSuperClone.html
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-Reports clone() methods which do not call super.clone().
-Cloning an object without calling super.clone() may result in objects being improperly initialized.
-
-- - - \ No newline at end of file diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/FinalizeCallsSuperFinalize.html b/plugins/InspectionGadgets/src/inspectionDescriptions/FinalizeCallsSuperFinalize.html deleted file mode 100644 index 7eb02c03f99d..000000000000 --- a/plugins/InspectionGadgets/src/inspectionDescriptions/FinalizeCallsSuperFinalize.html +++ /dev/null @@ -1,18 +0,0 @@ - -
-Reports any implementations of the Object.finalize() method -which do not call super.finalize(). Failing to call super.finalize() may result in objects failing to properly -free any resources held or do other cleanup activities. - --Use the checkboxes below to ignore direct subclasses of java.lang.Object -or to ignore finalize() implementations with an empty -method body or a body containing only if statements which have a condition which -evaluates to false at compile time. For performance reasons it can be beneficial to -override a non-trivial finalize() with an empty -implementation in a subclass. An empty final finalize() -implementation can also be used to prevent subclasses from overriding. -
- - - \ No newline at end of file diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/SetupCallsSuperSetup.html b/plugins/InspectionGadgets/src/inspectionDescriptions/SetupCallsSuperSetup.html deleted file mode 100644 index 114eaf56cf02..000000000000 --- a/plugins/InspectionGadgets/src/inspectionDescriptions/SetupCallsSuperSetup.html +++ /dev/null @@ -1,9 +0,0 @@ - -
-Reports JUnit classes whose setUp() method -does not call super.setUp(). - -- - - \ No newline at end of file diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/TeardownCallsSuperTeardown.html b/plugins/InspectionGadgets/src/inspectionDescriptions/TeardownCallsSuperTeardown.html deleted file mode 100644 index 369631f19b5f..000000000000 --- a/plugins/InspectionGadgets/src/inspectionDescriptions/TeardownCallsSuperTeardown.html +++ /dev/null @@ -1,9 +0,0 @@ - -
-Reports JUnit classes whose tearDown() method -does not call super.tearDown(). - -
-
-
-
\ No newline at end of file
diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/cloneable/clone_calls_super_clone/CloneCallsSuperClone.java b/plugins/InspectionGadgets/test/com/siyeh/igtest/cloneable/clone_calls_super_clone/CloneCallsSuperClone.java
deleted file mode 100644
index 3a95546ee4f8..000000000000
--- a/plugins/InspectionGadgets/test/com/siyeh/igtest/cloneable/clone_calls_super_clone/CloneCallsSuperClone.java
+++ /dev/null
@@ -1,36 +0,0 @@
-package com.siyeh.igtest.cloneable.clone_calls_super_clone;
-
-public class CloneCallsSuperClone implements Cloneable
-{
-
- public void foo()
- {
-
- }
-
- public Object