struct Ameba::Rule::Lint::ComparisonToBoolean
- Ameba::Rule::Lint::ComparisonToBoolean
- Ameba::Rule::Base
- Struct
- Value
- Object
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.crConstant Summary
-
MSG =
"Comparison to a boolean is pointless"
Constructors
-
.new(config = nil)
A rule that disallows comparison to booleans.
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