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.
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.
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.
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
| "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.
| 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