rspec/rules/S864/description.adoc
2022-05-13 10:24:14 +00:00

19 lines
984 B
Plaintext

The rules of operator precedence are complicated and can lead to errors. For this reason, parentheses should be used for clarification in complex statements. However, this does not mean that parentheses should be gratuitously added around every operation.
This rule raises issues when ``++&&++`` and ``++||++`` are used in combination, when assignment and equality or relational operators are used together in a condition, and for other operator combinations according to the following table:
[frame=all]
[cols="^1,^1,^1,^1,^1,^1"]
|===
||``+``, ``++-++``, ``++*++``, ``++/++``, ``++%++``|``++<<++``, ``++>>++``, ``++>>>++``|``++&++``|``++^++``| ``++\|++``
|``+``, ``++-++``, ``++*++``, ``++/++``, ``++%++``| |x|x|x|x
|``++<<++``, ``++>>++``, ``++>>>++``|x| |x|x|x
|``++&++``|x|x| |x|x
|``++^++``|x|x|x| |x
| ``++\|++`` |x|x|x|x|
|===
This rule also raises an issue when the "true" or "false" expression of a ternary operator is not trivial and not wrapped inside parentheses.