[jvm-inspections] IDEA-310343 Patterns as arguments for logging

GitOrigin-RevId: 904ee15422954df774ea8514ee86a453a8e53ded
This commit is contained in:
Mikhail Pyltsin
2023-01-23 17:42:49 +01:00
committed by intellij-monorepo-bot
parent 0aa8fb366c
commit 22e67cafdd

View File

@@ -34,13 +34,13 @@ private class LoggingStringTemplateAsArgumentVisitor(
if (valueArguments.isEmpty()) return true
var stringExpression = valueArguments[0]
var indexStringExpression = 0
if (!canBePattern(stringExpression.getExpressionType())) {
if (!canBeText(stringExpression.getExpressionType())) {
if (valueArguments.size < 2) {
return true
}
stringExpression = valueArguments[1]
indexStringExpression = 1
if (!canBePattern(stringExpression.getExpressionType())) {
if (!canBeText(stringExpression.getExpressionType())) {
return true
}
}
@@ -61,7 +61,7 @@ private class LoggingStringTemplateAsArgumentVisitor(
!stringExpression.operands.all { it is ULiteralExpression }
}
private fun canBePattern(expressionType: PsiType?): Boolean {
private fun canBeText(expressionType: PsiType?): Boolean {
if (
expressionType?.equalsToText(CommonClassNames.JAVA_LANG_STRING) == true ||
expressionType?.equalsToText(CommonClassNames.JAVA_LANG_CHAR_SEQUENCE) == true