The use of comparison operators (``++<++``, ``++<=++``, ``++>=++``, ``++>++``) with strings is not likely to yield the expected results. Make sure the intention was to compare strings and not numbers.
\[~ann.campbell.2] I'm stuck with this rule. Could you help me with a draft?
Initially idea was to check that binary operations are called with operands of same type. But further investigations shown that it's common practice to use what ever types you want :)
So I found out cases when expected result might differ from actual (see SONARJS-450), and I think that this rule should check only these particular cases. Now I don't know what should be the description and especially the title of this rule.
=== on 18 Nov 2015, 19:51:22 Ann Campbell wrote:
Okay [~elena.vilchik], let's narrow this down. We want to raise an issue when:
* String is compared (<, >, +<=+, >=, ==(?), ===(?)) with ... anything? Linked ticket shows ``++str1 < str2++`` but it seems that it would be equally faulty with ``++str1 < obj++`` and ``++str1 >= 4++`` ...?
* Strings are concatenated with non-strings
* dis-similar types are checked for (in)equality. Is this only ``++===++`` or ``++==++`` as well?
=== on 19 Nov 2015, 11:34:42 Elena Vilchik wrote:
\[~ann.campbell.2] Not exactly. It should be this way:
* string compared with string only (<, >, +<=+, >=)