Miscellaneous-NoConstOnLHS

Put constants on right side of equality comparisons in conditions

Required inputs: IR

When a variable is compared with a constant, put the constant on the right-hand side of the comparison. This rule reports == comparisons where the right-hand side is a mutable lvalue, and the left-hand side is either an rvalue or a const-qualified lvalue.

Possible Messages

Key

Text

Severity

Disabled

mut_lvalue_should_be_lhs

Put mutable lvalue operand on left side of equality comparisons.

None

False

Options

only_report_compile_time_constant

only_report_compile_time_constant : bool = False

If set, only report a violation if the left-hand side is a compile-time constant. If this option is false, will also report violations if the left-hand side is an rvalue (e.g. `other_value + 1 == value`) or a const-qualified lvalue (e.g. `*ptr_to_const == value`).