struct Ameba::Rule::Lint::ComparisonToBoolean

Overview

A rule that disallows comparison to booleans.

For example, these are considered invalid:

foo == true
bar != false
false === baz

This is because these expressions evaluate to true or false, so you could get the same result by using either the variable directly, or negating the variable.

YAML configuration example:

Lint/ComparisonToBoolean:
  Enabled: true

Defined in:

ameba/rule/lint/comparison_to_boolean.cr

Constant Summary

MSG = "Comparison to a boolean is pointless"

Constructors

Instance Method Summary

Instance methods inherited from struct Ameba::Rule::Base

catch(source : Source) catch, excluded?(source) excluded?, group group, initialize initialize, name name, special? special?, test(source : Source, node : Crystal::ASTNode, *opts)
test(source : Source)
test

Constructor methods inherited from struct Ameba::Rule::Base

new new

Class methods inherited from struct Ameba::Rule::Base

parsed_doc parsed_doc

Constructor Detail

def self.new(config = nil) #

A rule that disallows comparison to booleans.

For example, these are considered invalid:

foo == true
bar != false
false === baz

This is because these expressions evaluate to true or false, so you could get the same result by using either the variable directly, or negating the variable.

YAML configuration example:

Lint/ComparisonToBoolean:
  Enabled: true

[View source]

Instance Method Detail

def test(source, node : Crystal::Call) #

[View source]
def test(source) #

[View source]