2023-05-03 11:06:20 +02:00
|
|
|
== Why is this an issue?
|
|
|
|
|
2021-06-08 14:23:48 +02:00
|
|
|
A conditional operator is sometimes cluttering readability, if one of the operand is a boolean literal it can be simplified in a boolean expression :
|
|
|
|
|
|
|
|
|
2023-05-03 11:06:20 +02:00
|
|
|
=== Compliant solution
|
2021-06-08 14:23:48 +02:00
|
|
|
|
2022-02-04 17:28:24 +01:00
|
|
|
[source,java]
|
2021-06-08 14:23:48 +02:00
|
|
|
----
|
|
|
|
boolean a = condition || exp;
|
|
|
|
boolean a = !condition && exp;
|
|
|
|
boolean a = !condition || exp;
|
|
|
|
boolean a = condition && exp;
|
|
|
|
----
|
|
|
|
|
|
|
|
|
|
|
|
ifdef::env-github,rspecator-view[]
|
2021-06-08 15:52:13 +02:00
|
|
|
'''
|
2021-06-08 14:23:48 +02:00
|
|
|
== Comments And Links
|
|
|
|
(visible only on this page)
|
|
|
|
|
2023-05-25 14:18:12 +02:00
|
|
|
=== duplicates: S1125
|
|
|
|
|
|
|
|
=== on 22 Aug 2014, 08:37:01 Nicolas Peru wrote:
|
|
|
|
As discussed yesterday, feel free to challenge it.
|
|
|
|
|
|
|
|
=== on 22 Aug 2014, 19:46:19 Ann Campbell wrote:
|
|
|
|
\[~nicolas.peru] I can't think of a way to word this that's not a pure duplicate of RSPEC-1125. I think we should just roll this into that rule. WDYT?
|
|
|
|
|
2021-06-08 14:23:48 +02:00
|
|
|
endif::env-github,rspecator-view[]
|