rspec/rules/S2752/rule.adoc
2022-02-04 16:28:24 +00:00

15 lines
433 B
Plaintext

Logical expressions that always return the same value can more cleanly and clearly be replaced with that value. More probably, the fact that such expressions always return the same value is an indication of an error in the logic.
== Noncompliant Code Example
[source,text]
----
int i = 2;
int j = 4;
int k = true ? i : j; // Noncompliant; k always assigned i's value
int m = i > j ? i+2: j -1; // Noncompliant; m always 3
----