-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
collapsible_if: split collapsible_else_if into its own lint so we can enable/disable it particularly #6544
Conversation
r? @flip1995 (rust-highfive has picked a reviewer for you, use r? to override) |
pub COLLAPSIBLE_ELSE_IF, | ||
style, |
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.
Having the split out lint in the style
category will result in people having to allow this lint again in their code, if they don't like it.
I guess the argument that this is fine, is that this case of the lint is easier to fix than the other case?
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.
Yeah, hopefully it won't be too annoying. :/
I also think that the if {} else { if {} }
warning is actually more useful than the if { if {} }
warning.
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.
Looking at your Rust PR, where you linked to this, it seems Joshua also agrees. So I'm ok with this.
clippy_lints/src/collapsible_if.rs
Outdated
style, | ||
"`if`s that can be collapsed (e.g., `if x { if y { ... } }` and `else { if x { ... } }`)" | ||
"nested `else`-`if` expressions that can be collapsed (e.g., `else { if x { ... } }`)" | ||
} | ||
|
||
declare_lint_pass!(CollapsibleIf => [COLLAPSIBLE_IF]); |
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.
declare_lint_pass!(CollapsibleIf => [COLLAPSIBLE_IF]); | |
declare_lint_pass!(CollapsibleIf => [COLLAPSIBLE_IF, COLLAPSIBLE_ELSE_IF]); |
r=me with CI passing. |
… enable/disable it particularly This splits up clippy::collapsible_if into collapsible_if for if x { if y { } } => if x && y { } and collapsible_else_if for if x { } else { if y { } } => if x { } else if y { } so that we can lint for only the latter but not the first if we desire. changelog: collapsible_if: split up linting for if x {} else { if y {} } into collapsible_else_if lint
@bors r=flip1995 |
📌 Commit 6dcec6a has been approved by |
☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test |
This splits up clippy::collapsible_if into collapsible_if for
if x {
if y { }
}
=>
if x && y { }
and collapsible_else_if for
if x {
} else {
if y { }
}
=>
if x {
} else if y {
}
so that we can lint for only the latter but not the first if we desire.
changelog: collapsible_if: split up linting for if x {} else { if y {} } into collapsible_else_if lint