haxe-checkstyle
haxe-checkstyle copied to clipboard
Add check for NestedTernaryOperator
Detects ternary operators which are located within one of the cases of another ternary operator. Many developers find simple ternary operators easy to read, but quickly become overwhelmed when several are included in one statement. This check can be resolved by refactoring with if/else conditional blocks.
Configuration
{
"type": "NestedTernaryOperator",
"props": {
"severity": "ERROR"
}
}
Invalid
var value = (event.keyCode != null) ? (event.keyCode == KeyCode.ENTER) ? 10 : 5 : 1;
Valid
var value = 1;
if (event.keyCode != null) {
value = (event.keyCode == KeyCode.ENTER) ? 10 : 5;
}