From 12b8a0ac148f7fa3120ba99b61b24c5601a7afcf Mon Sep 17 00:00:00 2001 From: Georg Brandl Date: Sun, 17 Apr 2016 12:52:38 +0200 Subject: [PATCH] Make if_not_else lint Allow by default (fixes #859) --- README.md | 2 +- src/if_not_else.rs | 2 +- src/lib.rs | 2 +- tests/compile-fail/entry.rs | 2 +- tests/compile-fail/if_not_else.rs | 1 + 5 files changed, 5 insertions(+), 4 deletions(-) mode change 100644 => 100755 tests/compile-fail/entry.rs mode change 100644 => 100755 tests/compile-fail/if_not_else.rs diff --git a/README.md b/README.md index c7cee794db45..80d26cdede04 100644 --- a/README.md +++ b/README.md @@ -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_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` -[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 [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 diff --git a/src/if_not_else.rs b/src/if_not_else.rs index ebc2ce76fec9..2fc2cc10e387 100644 --- a/src/if_not_else.rs +++ b/src/if_not_else.rs @@ -14,7 +14,7 @@ use utils::span_help_and_lint; /// /// **Example:** if !v.is_empty() { a() } else { b() } 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" } diff --git a/src/lib.rs b/src/lib.rs index c1a7732e3f5b..0f005152239c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -237,6 +237,7 @@ pub fn plugin_registrar(reg: &mut Registry) { array_indexing::INDEXING_SLICING, booleans::NONMINIMAL_BOOL, enum_glob_use::ENUM_GLOB_USE, + if_not_else::IF_NOT_ELSE, matches::SINGLE_MATCH_ELSE, methods::OPTION_UNWRAP_USED, methods::RESULT_UNWRAP_USED, @@ -289,7 +290,6 @@ pub fn plugin_registrar(reg: &mut Registry) { formatting::SUSPICIOUS_ELSE_FORMATTING, functions::TOO_MANY_ARGUMENTS, identity_op::IDENTITY_OP, - if_not_else::IF_NOT_ELSE, items_after_statements::ITEMS_AFTER_STATEMENTS, len_zero::LEN_WITHOUT_IS_EMPTY, len_zero::LEN_ZERO, diff --git a/tests/compile-fail/entry.rs b/tests/compile-fail/entry.rs old mode 100644 new mode 100755 index e65ef503ba52..7dc4054ec5bf --- a/tests/compile-fail/entry.rs +++ b/tests/compile-fail/entry.rs @@ -1,6 +1,6 @@ #![feature(plugin)] #![plugin(clippy)] -#![allow(unused, if_not_else)] +#![allow(unused)] #![deny(map_entry)] diff --git a/tests/compile-fail/if_not_else.rs b/tests/compile-fail/if_not_else.rs old mode 100644 new mode 100755 index eb716e4599ab..a72699adafd8 --- a/tests/compile-fail/if_not_else.rs +++ b/tests/compile-fail/if_not_else.rs @@ -1,6 +1,7 @@ #![feature(plugin)] #![plugin(clippy)] #![deny(clippy)] +#![deny(if_not_else)] fn bla() -> bool { unimplemented!() }