javascript:S3512 - Template strings should be used instead of concatenation

Compliant solution to fix this is suggested using ``(back quote). But the ` is not understood by Testing frameworks like Jasmine. Is there any other way to have concatenation?

  • which versions are you using ? Enterprise Edition Version 8.5.1 (build 38104)
  • what are you trying to achieve ?
  • what have you tried so far to achieve this

Hello @Mohammed_Abdul_Aleem,

Welcome to SonarSource community!

In order to help you, I would need a minimal code sample that reproduces the problem you are facing.

Thank you,
Yassin

Thanks Yassin for your response.
Here is the sample

$(’#’ + controlId + ‘_label’).show();

Best,
Abdul Aleem

Hello again,

Thank you for the code reproducer. Unfortunately, I didn’t manage to repeat the issue you’re encountering. I created a minimal project with Jasmine dependency, and template literals work just fine.

I am not sure which version of Jasmine you are using, but if template literals don’t work with this test framework, you better report that issue to Jasmine folks as it is outside our scope of action.

Coming back to your initial question, and given the problem you are facing, I don’t see any other solution for you than disabling the rule as long as you can’t use template literals in your source code.

Hope this helps,
Yassin