struct Ameba::Rules::LiteralInCondition
- Ameba::Rules::LiteralInCondition
- Ameba::Rule
- Struct
- Value
- Object
Overview
A rule that disallows useless conditional statements that contain a literal in place of a variable or predicate function.
This is because a conditional construct with a literal predicate will always result in the same behaviour at run time, meaning it can be replaced with either the body of the construct, or deleted entirely.
This is considered invalid:
if "something"
:ok
end
Included Modules
Defined in:
ameba/rules/literal_in_condition.crInstance Method Summary
- #check_node(source, node)
- #test(source, node : Crystal::If)
- #test(source, node : Crystal::Unless)
- #test(source, node : Crystal::Case)
- #test(source)
Instance methods inherited from module Ameba::AST::Util
literal?(node)
literal?,
string_literal?(node)
string_literal?
Instance methods inherited from struct Ameba::Rule
catch(source : Source)
catch,
initialize
initialize,
name
name,
test(source : Source, node : Crystal::ASTNode)test(source : Source) test