mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-138606 ("Result of '...' not thrown" false positive if case of simple getter)
This commit is contained in:
+3
-3
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2008-2014 Bas Leijdekkers
|
||||
* Copyright 2008-2015 Bas Leijdekkers
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -18,8 +18,8 @@ package com.siyeh.ig.bugs;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.search.searches.ReferencesSearch;
|
||||
import com.intellij.psi.util.InheritanceUtil;
|
||||
import com.intellij.psi.util.PropertyUtil;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.psi.util.PsiUtil;
|
||||
import com.intellij.util.Query;
|
||||
import com.siyeh.InspectionGadgetsBundle;
|
||||
import com.siyeh.ig.BaseInspection;
|
||||
@@ -74,7 +74,7 @@ public class ThrowableResultOfMethodCallIgnoredInspection
|
||||
return;
|
||||
}
|
||||
final PsiMethod method = expression.resolveMethod();
|
||||
if (method == null) {
|
||||
if (method == null || PropertyUtil.isSimpleGetter(method)) {
|
||||
return;
|
||||
}
|
||||
if (!method.hasModifierProperty(PsiModifier.STATIC)) {
|
||||
|
||||
+16
-1
@@ -2,7 +2,7 @@ package com.siyeh.igtest.bugs.throwable_result_of_method_call_ignored;
|
||||
|
||||
|
||||
|
||||
public class A {
|
||||
public class ThrowableResultOfMethodCallIgnored {
|
||||
public static void test() {
|
||||
try {
|
||||
<warning descr="Result of 'firstNonNull()' not thrown">firstNonNull</warning>(new Throwable(), null);
|
||||
@@ -24,3 +24,18 @@ public class A {
|
||||
return new RuntimeException();
|
||||
}
|
||||
}
|
||||
class ResWrap {
|
||||
private String payload;
|
||||
private Throwable error;
|
||||
|
||||
public Throwable getError() {
|
||||
return error;
|
||||
}
|
||||
public ResWrap service() {
|
||||
final ResWrap result = new ResWrap();
|
||||
if (result.getError() == null) {
|
||||
//rememberResult(result.payload);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -6,7 +6,7 @@ import com.siyeh.ig.LightInspectionTestCase;
|
||||
|
||||
public class ThrowableResultOfMethodCallIgnoredInspectionTest extends LightInspectionTestCase {
|
||||
|
||||
public void testA() throws Exception {
|
||||
public void testThrowableResultOfMethodCallIgnored() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user