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

New Check: Nested Ternary #98

daniilyar opened this issue Jan 14, 2013 · 0 comments

New Check: Nested Ternary #98

daniilyar opened this issue Jan 14, 2013 · 0 comments


Copy link

@daniilyar daniilyar commented Jan 14, 2013

We need a check that forbids nested ternary operators. Example:

int smth = (a == b) ? -1 : (c == d) ? 0 : 1; 

This is really a bad practice.. This line should be refactored to:

int k;
if (a == b) {
    k = -1;
} else {
    if (c == d) {
    k = 0;
    else {
        k = 1;

Check should have a single option named 'ignore final' which allows to ignore statements such as:

final int smth = (a == b) ? -1 : (c == d) ? 0 : 1; 

in ctors, because in c-tors there is only one way to deal with such kind of logical operations on final variable.

@ghost ghost assigned daniilyar Jan 16, 2013
daniilyar pushed a commit to daniilyar/sevntu.checkstyle that referenced this issue Jan 19, 2013
@romani romani closed this in b2cae4e Feb 6, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.