boolean (PsiExpression expression) { if (!TypeUtils.isJavaLangString(expression.getType()) || ControlFlowUtils.isInExitStatement(expression) || !ControlFlowUtils.isInLoop(expression)) return false; PsiElement parent = expression; while (parent instanceof PsiParenthesizedExpression || parent instanceof PsiPolyadicExpression) { parent = parent.getParent(); } if (parent != expression && parent instanceof PsiAssignmentExpression && ((PsiAssignmentExpression)parent).getOperationTokenType().equals(JavaTokenType.PLUSEQ)) { // Will be reported for parent +=, no need to report twice return false; } if (parent instanceof PsiAssignmentExpression) { expression = (PsiExpression)parent; PsiReferenceExpression lhs = getAppendedExpression(expression); if (lhs == null) return false; PsiVariable variable = ObjectUtils.tryCast(lhs.resolve(), PsiVariable.class); if (variable != null) { PsiLoopStatement commonLoop = getOutermostCommonLoop(expression, variable); return commonLoop != null && !ControlFlowUtils.isExecutedOnceInLoop(PsiTreeUtil.getParentOfType(expression, PsiStatement.class), commonLoop) && !isUsedCompletely(variable, commonLoop) && checkQualifier(lhs, commonLoop); } } return false; }