rspec/rules/S5263/rule.adoc
2021-01-27 13:42:22 +01:00

22 lines
595 B
Plaintext
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

While working with bitwise operators ``++&++`` or ``++|++`` it is easy to make a typo and write the equivalent logical operators ``++&&++`` or ``++||++``. This rule is raising issues when the right operand of a logical expression ``++&&++`` or ``++||++`` is a constant of integral type, as the developer probably meant to use the corresponding bitwise operator ``++&++`` or ``++|++``.
== Noncompliant Code Example
----
int fun(int a) {
return a || 4; // Noncompliant, did you mean to use bitwise operator '|'?
}
----
== Compliant Solution
----
int fun(int a) {
return a | 4;
}
----