Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add check for NestedTernaryOperator #510

Open
EliteMasterEric opened this issue Sep 9, 2021 · 0 comments
Open

Add check for NestedTernaryOperator #510

EliteMasterEric opened this issue Sep 9, 2021 · 0 comments

Comments

@EliteMasterEric
Copy link

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;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants