haxe-checkstyle icon indicating copy to clipboard operation
haxe-checkstyle copied to clipboard

Add check for string interpolation

Open pypmannetjies opened this issue 8 years ago • 3 comments

It would be cool to add a rule which prefers string interpolation over using + on strings.

E.g.

var s = "Hello " + name; // Error
var s = 'Hello ${name}' // No error

pypmannetjies avatar Sep 14 '17 13:09 pypmannetjies

It's probably easy to find all String constants, but using string interpolation might not make sense in all cases. e.g. when splitting strings over multiple lines for formatting or when you have a long and complicated expression instead of just name.

AlexHaxe avatar Sep 14 '17 14:09 AlexHaxe

That particular example should probably still error, because $name should be preferred over ${name}.

Gama11 avatar Sep 14 '17 19:09 Gama11

@AlexHaxe that makes sense. Perhaps the check could cater for only checking single line expressions?

pypmannetjies avatar Sep 15 '17 07:09 pypmannetjies