mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IG: result of getters should not be ignored
This commit is contained in:
+5
@@ -21,6 +21,7 @@ import com.intellij.openapi.util.InvalidDataException;
|
||||
import com.intellij.openapi.util.WriteExternalException;
|
||||
import com.intellij.openapi.util.registry.Registry;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.util.PropertyUtil;
|
||||
import com.intellij.psi.util.PsiUtilCore;
|
||||
import com.siyeh.InspectionGadgetsBundle;
|
||||
import com.siyeh.ig.BaseInspection;
|
||||
@@ -136,6 +137,10 @@ public class IgnoreResultOfCallInspectionBase extends BaseInspection {
|
||||
if (PsiUtilCore.hasErrorElementChild(statement)) {
|
||||
return;
|
||||
}
|
||||
if (PropertyUtil.isSimpleGetter(method)) {
|
||||
registerMethodCallError(call, aClass);
|
||||
return;
|
||||
}
|
||||
if (m_reportAllNonLibraryCalls && !LibraryUtil.classIsInLibrary(aClass)) {
|
||||
registerMethodCallError(call, aClass);
|
||||
return;
|
||||
|
||||
+12
@@ -82,6 +82,18 @@ public class IgnoreResultOfCallInspectionTest extends LightInspectionTestCase {
|
||||
"}");
|
||||
}
|
||||
|
||||
public void testRandomGetter() {
|
||||
doTest("class A {" +
|
||||
" private String name;" +
|
||||
" public String getName() {" +
|
||||
" return name;" +
|
||||
" }" +
|
||||
" void m() {" +
|
||||
" /*Result of 'A.getName()' is ignored*/getName/**/();" +
|
||||
" }" +
|
||||
"}")
|
||||
}
|
||||
|
||||
public void testJSR305Annotation2() {
|
||||
doTest("import javax.annotation.CheckReturnValue;" +
|
||||
"@CheckReturnValue " +
|
||||
|
||||
Reference in New Issue
Block a user