Skip to content

boolean-symbol

Rubysuspiciousno fixdefault: warnruby/rubocop

Reports the symbol :true or :false.

:true is a symbol, and in a condition it is truthy like any other symbol, including :false. It is almost always a boolean meant to be true or false.

To fix, write true or false.

Reported
x = :true
y = :ok
...
end
...
h = { true: 1 }
ruby:
lint:
rules:
boolean-symbol: warn # off, warn (default), error

Enabled by the presets: ruby/rubocop.

Suppress one line with sudsy-disable-next-line boolean-symbol in a comment of the file’s language.

The same check in other tools. full: Sudsy reports what the upstream rule reports; partial: only part of it, as the last column says.

Tool Rule Match What differs
rubocop Lint/BooleanSymbol partial # rubocop:disable comments are not read