Detekt: New rule: report string concatenation that could be a string template

Created on 27 Nov 2019  路  3Comments  路  Source: detekt/detekt

Expected Behavior of the rule

Non Compliant

val foo = "test = " + bar

Compliant

val foo = "test = $bar"
val baz = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" +
     "bbbbbbbbbbbbbbb"

It doesn't report if the concatenation is at the end of the line.

Happy to contribute this one 馃槂

rules wontdo

Most helpful comment

Ok no problem, we already have this as a custom rule 馃槃

All 3 comments

Thanks for your contribution!
For me, this seems to be a matter of taste.
We try to include contributed rules that are useful for the majority of detekt's user base. I don't think this is the case here, since it doesn't matter which type of style I use. The generated code looks the same for both code snippets.
If you really need this rule for your team, I'd ask you to write a custom domain specific rule [1].
We are happy to help out, if you have any questions.

[1] https://arturbosch.github.io/detekt/extensions.html#custom-rulesets

Ok no problem, we already have this as a custom rule 馃槃

Nice! I鈥檓 happy to hear that the custom rule integration feature works for you.

Was this page helpful?
0 / 5 - 0 ratings