org.codenarc.rule.basic
[Groovy] Class ConstantTernaryExpressionRule
java.lang.Object
org.codenarc.rule.AbstractRule
org.codenarc.rule.AbstractAstVisitorRule
org.codenarc.rule.basic.ConstantTernaryExpressionRule
class ConstantTernaryExpressionRule
extends AbstractAstVisitorRule
Rule that checks for ternary expressions with a constant value for the boolean expression, such as:
true ? x : y
false ? x : y
Boolean.TRUE ? x : y
Boolean.FALSE ? x : y
null ? x : y
0 ? x : y
99.7 ? x : y
"" ? x : y
"abc" ? x : y
[:] ? x : y
[a:123, b:456] ? x : y
[a, b, c] ? x : y
Also checks for the same types of constant values for the boolean expressions within the "short"
ternary expressions, also known as the "Elvis" operator, e.g.:
true ?: y
null ?: y
99.7 ?: y
"abc" ?: y
[a:123] ?: y
- Authors:
- Chris Mair
- Version:
- \$Revision: 553 \$ - \$Date: 2011-01-20 16:07:46 -0500 (Thu, 20 Jan 2011) \$
Methods inherited from class AbstractRule
|
applyTo, applyTo, createViolation, createViolation, createViolationForImport, createViolationForImport, getImportsSortedByLineNumber, getName, getPriority, isReady, packageNameForImport, setName, setPriority, sourceLineAndNumberForImport, sourceLineAndNumberForImport, toString, validate |
astVisitorClass
Class astVisitorClass
-
name
String name
-
priority
int priority
-
Groovy Documentation