Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
Description of the false positive
Thanks for your report. We deliberately flag code whose only potential effect looks unintentional, and the cases where a coercion happens for its side effects alone are so rare that it's best to clarify the intent with a suppression comment. I can see you've already done so for a few other tools, but unfortunately LGTM does not understand ESLint or jscs suppression comments.
So if you're willing to add yet another a suppression comment to your collection, it would look like this:
'' + str; // jscs:ignore disallowImplicitTypeConversion lgtm[js/useless-expression]
Alternatively, the whole query can be disabled by checking in an
queries: - exclude: js/useless-expression
I'm not willing to add either, unfortunately; it might be wise for LGTM to add support for eslint suppression comments, since that's the defacto standard in the ecosystem.
In this specific case, however, since it's inside a try/catch, i don't think your heuristic should flag it.