Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add check for string interpolation #358

Open
pypmannetjies opened this issue Sep 14, 2017 · 3 comments
Open

Add check for string interpolation #358

pypmannetjies opened this issue Sep 14, 2017 · 3 comments

Comments

@pypmannetjies
Copy link
Contributor

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 pypmannetjies changed the title New check for string interpolation Add check for string interpolation Sep 14, 2017
@AlexHaxe
Copy link
Member

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.

@Gama11
Copy link
Member

Gama11 commented Sep 14, 2017

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

@pypmannetjies
Copy link
Contributor Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants