Class RedundantBooleanComparisonOrError
java.lang.Object
org.ek9lang.compiler.common.RuleSupport
org.ek9lang.compiler.common.TypedSymbolAccess
org.ek9lang.compiler.phase5.RedundantBooleanComparisonOrError
- All Implemented Interfaces:
Consumer<EK9Parser.ExpressionContext>
final class RedundantBooleanComparisonOrError
extends TypedSymbolAccess
implements Consumer<EK9Parser.ExpressionContext>
Detects comparisons of a Boolean expression with a Boolean literal (E08084).
Expressions like b == true should be simplified to b,
and b == false should be simplified to not b. The comparison
adds unnecessary verbosity and indicates a misunderstanding of Boolean logic.
Only equality operators (==, <>, !=) are checked.
Comparing two Boolean variables (a == b) is valid and not flagged.
-
Field Summary
Fields inherited from class RuleSupport
errorListener, symbolsAndScopes -
Constructor Summary
ConstructorsConstructorDescriptionRedundantBooleanComparisonOrError(SymbolsAndScopes symbolsAndScopes, ErrorListener errorListener) -
Method Summary
Methods inherited from class TypedSymbolAccess
getRecordedAndTypedSymbol, isProcessingScopePure, recordATypedSymbol
-
Constructor Details
-
RedundantBooleanComparisonOrError
RedundantBooleanComparisonOrError(SymbolsAndScopes symbolsAndScopes, ErrorListener errorListener)
-
-
Method Details
-
accept
- Specified by:
acceptin interfaceConsumer<EK9Parser.ExpressionContext>
-