mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
disable "call always fails according to method contract" in tests (IDEA-168613)
1. test might check precisely this failure 2. even if not, the test will fail anyway and the mistake will be obvious quite soon
This commit is contained in:
+5
@@ -39,6 +39,7 @@ import com.intellij.codeInspection.nullable.NullableStuffInspectionBase;
|
||||
import com.intellij.lang.java.JavaLanguage;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.roots.ProjectFileIndex;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.util.WriteExternalException;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
@@ -401,6 +402,10 @@ public class DataFlowInspectionBase extends BaseJavaBatchLocalInspectionTool {
|
||||
private static void reportAlwaysFailingCalls(ProblemsHolder holder,
|
||||
DataFlowInstructionVisitor visitor,
|
||||
HashSet<PsiElement> reportedAnchors) {
|
||||
if (ProjectFileIndex.SERVICE.getInstance(holder.getProject()).isInTestSourceContent(holder.getFile().getViewProvider().getVirtualFile())) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (PsiCall call : visitor.getAlwaysFailingCalls()) {
|
||||
PsiMethod method = call.resolveMethod();
|
||||
if (method != null && reportedAnchors.add(call)) {
|
||||
|
||||
+17
@@ -76,4 +76,21 @@ class DataFlowInspectionHeavyTest extends JavaCodeInsightFixtureTestCase {
|
||||
public @interface Nullable {}
|
||||
"""
|
||||
}
|
||||
|
||||
void "test no always failing calls in tests"() {
|
||||
PsiTestUtil.addSourceRoot(myModule, myFixture.tempDirFixture.findOrCreateDir("test"), true)
|
||||
|
||||
myFixture.configureFromExistingVirtualFile(myFixture.addFileToProject("test/Foo.java", """
|
||||
class Foo {
|
||||
void foo() {
|
||||
assertTrue(false);
|
||||
}
|
||||
private void assertTrue(boolean b) {
|
||||
if (!b) throw new RuntimeException();
|
||||
}
|
||||
}
|
||||
""").virtualFile)
|
||||
myFixture.enableInspections(new DataFlowInspection())
|
||||
myFixture.checkHighlighting()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user