void (@NotNull PsiReturnStatement statement) { super.visitReturnStatement(statement); final PsiExpression returnValue = PsiUtil.deparenthesizeExpression(statement.getReturnValue()); if (!(returnValue instanceof PsiReferenceExpression)) { return; } final PsiElement element = PsiTreeUtil.getParentOfType(statement, PsiMethod.class, PsiLambdaExpression.class); if (ignorePrivateMethods && element instanceof PsiMethod && ((PsiMethod)element).hasModifierProperty(PsiModifier.PRIVATE)) { return; } final PsiField field = ObjectUtils.tryCast(((PsiReferenceExpression)returnValue).resolve(), PsiField.class); if (field == null) return; final String type = TypeUtils.expressionHasTypeOrSubtype(returnValue, MUTABLE_TYPES); if (type == null && !(returnValue.getType() instanceof PsiArrayType)) return; if (CollectionUtils.isConstantEmptyArray(field) || field.hasModifierProperty(PsiModifier.FINAL) && field.hasModifierProperty(PsiModifier.STATIC) && field.getType() instanceof PsiArrayType && field.getInitializer() == null || ClassUtils.isImmutable(field.getType()) || Mutability.getMutability(field).isUnmodifiable()) return; registerError(returnValue, field, returnValue, type, Boolean.FALSE); }