Merge pull request #861 from birkenfeld/issue859

Make if_not_else lint Allow by default (fixes #859)
This commit is contained in:
Martin Carton 2016-04-17 13:03:31 +02:00
commit b433327311
5 changed files with 5 additions and 4 deletions

View file

@ -61,7 +61,7 @@ name
[for_loop_over_option](https://github.com/Manishearth/rust-clippy/wiki#for_loop_over_option) | warn | for-looping over an `Option`, which is more clearly expressed as an `if let` [for_loop_over_option](https://github.com/Manishearth/rust-clippy/wiki#for_loop_over_option) | warn | for-looping over an `Option`, which is more clearly expressed as an `if let`
[for_loop_over_result](https://github.com/Manishearth/rust-clippy/wiki#for_loop_over_result) | warn | for-looping over a `Result`, which is more clearly expressed as an `if let` [for_loop_over_result](https://github.com/Manishearth/rust-clippy/wiki#for_loop_over_result) | warn | for-looping over a `Result`, which is more clearly expressed as an `if let`
[identity_op](https://github.com/Manishearth/rust-clippy/wiki#identity_op) | warn | using identity operations, e.g. `x + 0` or `y / 1` [identity_op](https://github.com/Manishearth/rust-clippy/wiki#identity_op) | warn | using identity operations, e.g. `x + 0` or `y / 1`
[if_not_else](https://github.com/Manishearth/rust-clippy/wiki#if_not_else) | warn | finds if branches that could be swapped so no negation operation is necessary on the condition [if_not_else](https://github.com/Manishearth/rust-clippy/wiki#if_not_else) | allow | finds if branches that could be swapped so no negation operation is necessary on the condition
[if_same_then_else](https://github.com/Manishearth/rust-clippy/wiki#if_same_then_else) | warn | if with the same *then* and *else* blocks [if_same_then_else](https://github.com/Manishearth/rust-clippy/wiki#if_same_then_else) | warn | if with the same *then* and *else* blocks
[ifs_same_cond](https://github.com/Manishearth/rust-clippy/wiki#ifs_same_cond) | warn | consecutive `ifs` with the same condition [ifs_same_cond](https://github.com/Manishearth/rust-clippy/wiki#ifs_same_cond) | warn | consecutive `ifs` with the same condition
[indexing_slicing](https://github.com/Manishearth/rust-clippy/wiki#indexing_slicing) | allow | indexing/slicing usage [indexing_slicing](https://github.com/Manishearth/rust-clippy/wiki#indexing_slicing) | allow | indexing/slicing usage

View file

@ -14,7 +14,7 @@ use utils::span_help_and_lint;
/// ///
/// **Example:** if !v.is_empty() { a() } else { b() } /// **Example:** if !v.is_empty() { a() } else { b() }
declare_lint! { declare_lint! {
pub IF_NOT_ELSE, Warn, pub IF_NOT_ELSE, Allow,
"finds if branches that could be swapped so no negation operation is necessary on the condition" "finds if branches that could be swapped so no negation operation is necessary on the condition"
} }

View file

@ -237,6 +237,7 @@ pub fn plugin_registrar(reg: &mut Registry) {
array_indexing::INDEXING_SLICING, array_indexing::INDEXING_SLICING,
booleans::NONMINIMAL_BOOL, booleans::NONMINIMAL_BOOL,
enum_glob_use::ENUM_GLOB_USE, enum_glob_use::ENUM_GLOB_USE,
if_not_else::IF_NOT_ELSE,
matches::SINGLE_MATCH_ELSE, matches::SINGLE_MATCH_ELSE,
methods::OPTION_UNWRAP_USED, methods::OPTION_UNWRAP_USED,
methods::RESULT_UNWRAP_USED, methods::RESULT_UNWRAP_USED,
@ -289,7 +290,6 @@ pub fn plugin_registrar(reg: &mut Registry) {
formatting::SUSPICIOUS_ELSE_FORMATTING, formatting::SUSPICIOUS_ELSE_FORMATTING,
functions::TOO_MANY_ARGUMENTS, functions::TOO_MANY_ARGUMENTS,
identity_op::IDENTITY_OP, identity_op::IDENTITY_OP,
if_not_else::IF_NOT_ELSE,
items_after_statements::ITEMS_AFTER_STATEMENTS, items_after_statements::ITEMS_AFTER_STATEMENTS,
len_zero::LEN_WITHOUT_IS_EMPTY, len_zero::LEN_WITHOUT_IS_EMPTY,
len_zero::LEN_ZERO, len_zero::LEN_ZERO,

2
tests/compile-fail/entry.rs Normal file → Executable file
View file

@ -1,6 +1,6 @@
#![feature(plugin)] #![feature(plugin)]
#![plugin(clippy)] #![plugin(clippy)]
#![allow(unused, if_not_else)] #![allow(unused)]
#![deny(map_entry)] #![deny(map_entry)]

1
tests/compile-fail/if_not_else.rs Normal file → Executable file
View file

@ -1,6 +1,7 @@
#![feature(plugin)] #![feature(plugin)]
#![plugin(clippy)] #![plugin(clippy)]
#![deny(clippy)] #![deny(clippy)]
#![deny(if_not_else)]
fn bla() -> bool { unimplemented!() } fn bla() -> bool { unimplemented!() }