-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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 new lint else_if_without_else #2298
add new lint else_if_without_else #2298
Conversation
compiletest-rs failed to build (Manishearth/compiletest-rs#93) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm, just some doc nits
/// **What it does:** Checks for usage of if expressions with an else if branch, | ||
/// but without a final `else` branch. | ||
/// | ||
/// **Why is this bad?** Some coding guidelines require this. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you reference the MISRA standard rule here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep!
/// } else if x.is_negative() { | ||
/// b() | ||
/// } else { | ||
/// // we don't care about zero |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
zero is positive I think :D
just throw an unreachable!()
here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, {integer}.is_positive() returns false for 0, which is what I had in mind.
/// // we don't care about zero | ||
/// } | ||
/// ``` | ||
declare_lint! { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please make it a restriction lint. I don't think this should be part of the pedantic group
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok
91e82ea
to
f6f370e
Compare
f6f370e
to
40c6f43
Compare
Addressed comments (except for x.is_positive(), as noted earlier). |
retriggering travis |
retriggering travis |
Thanks! |
Thanks for the review! |
This lint checks that every
if
expression containing anelse if
has a terminatingelse
block.If
expressions withoutelse if
s and/orelse
s are not linted.cc #2227