Propose convert to string template as inspection more frequent
This commit is contained in:
committed by
Stanislav Erokhin
parent
4c15642e2c
commit
57e47d1830
@@ -51,9 +51,9 @@ open class ConvertToStringTemplateIntention : SelfTargetingOffsetIndependentInte
|
||||
fun shouldSuggestToConvert(expression: KtBinaryExpression): Boolean {
|
||||
val entries = buildReplacement(expression).entries
|
||||
return entries.none { it is KtBlockStringTemplateEntry }
|
||||
&& !entries.all { it is KtLiteralStringTemplateEntry || it is KtEscapeStringTemplateEntry }
|
||||
&& entries.count { it is KtLiteralStringTemplateEntry } > 1
|
||||
&& !expression.textContains('\n')
|
||||
&& !entries.all { it is KtLiteralStringTemplateEntry || it is KtEscapeStringTemplateEntry }
|
||||
&& entries.count { it is KtLiteralStringTemplateEntry } >= 1
|
||||
&& !expression.textContains('\n')
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
|
||||
@@ -7,4 +7,44 @@
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Convert string concatenation to string template</problem_class>
|
||||
<description>Convert concatenation to template</description>
|
||||
</problem>
|
||||
<problem>
|
||||
<file>noBracesSimpleFollowedByDot.kt</file>
|
||||
<line>3</line>
|
||||
<module>light_idea_test_case</module>
|
||||
<entry_point TYPE="file" FQNAME="noBracesSimpleFollowedByDot.kt" />
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">String concatenation that can be converted to string template</problem_class>
|
||||
<description>Convert concatenation to template</description>
|
||||
</problem>
|
||||
<problem>
|
||||
<file>specialCharsInCharLiteral.kt</file>
|
||||
<line>2</line>
|
||||
<module>light_idea_test_case</module>
|
||||
<entry_point TYPE="file" FQNAME="specialCharsInCharLiteral.kt" />
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">String concatenation that can be converted to string template</problem_class>
|
||||
<description>Convert concatenation to template</description>
|
||||
</problem>
|
||||
<problem>
|
||||
<file>doesNotCorruptExistingTemplate.kt</file>
|
||||
<line>4</line>
|
||||
<module>light_idea_test_case</module>
|
||||
<entry_point TYPE="file" FQNAME="doesNotCorruptExistingTemplate.kt" />
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">String concatenation that can be converted to string template</problem_class>
|
||||
<description>Convert concatenation to template</description>
|
||||
</problem>
|
||||
<problem>
|
||||
<file>unescapeSingleQuote.kt</file>
|
||||
<line>2</line>
|
||||
<module>light_idea_test_case</module>
|
||||
<entry_point TYPE="file" FQNAME="unescapeSingleQuote.kt" />
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">String concatenation that can be converted to string template</problem_class>
|
||||
<description>Convert concatenation to template</description>
|
||||
</problem>
|
||||
<problem>
|
||||
<file>noBracesForLastSimpleExpression.kt</file>
|
||||
<line>3</line>
|
||||
<module>light_idea_test_case</module>
|
||||
<entry_point TYPE="file" FQNAME="noBracesForLastSimpleExpression.kt" />
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">String concatenation that can be converted to string template</problem_class>
|
||||
<description>Convert concatenation to template</description>
|
||||
</problem>
|
||||
</problems>
|
||||
Reference in New Issue
Block a user