boolean (PsiExpression expression) { final PsiElement qualifier = PsiUtil.skipParenthesizedExprUp(expression); if (qualifier instanceof PsiReferenceExpression referenceExpression) { final PsiElement target = referenceExpression.resolve(); if (target instanceof PsiParameter) { return false; } else if (target instanceof PsiField field) { if (field.hasModifierProperty(PsiModifier.STATIC)) { return false; } else if (field.getContainingFile() == expression.getContainingFile()) { return false; } else if (ignoreLibraryCalls && field instanceof PsiCompiledElement) { return false; } return true; } else if (target instanceof PsiLocalVariable variable) { if (ignoreLibraryCalls && variable.getType() instanceof PsiArrayType) { return false; } final PsiExpression definition = DeclarationSearchUtils.findDefinition(referenceExpression, variable); return violatesLawOfDemeter(definition); } } else if (qualifier instanceof PsiMethodCallExpression methodCallExpression) { if (isCallToSuspiciousMethod(methodCallExpression)) { return true; } } return false; }