Move cognitive_complexity to nursery

This commit is contained in:
David Tolnay 2020-04-06 15:46:40 -07:00
parent f8308c811f
commit 899a1b5598
No known key found for this signature in database
GPG Key ID: F9BA143B95FF6D82
23 changed files with 48 additions and 58 deletions

View File

@ -77,7 +77,6 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for AssignOps {
},
hir::ExprKind::Assign(assignee, e, _) => {
if let hir::ExprKind::Binary(op, l, r) = &e.kind {
#[allow(clippy::cognitive_complexity)]
let lint = |assignee: &hir::Expr<'_>, rhs: &hir::Expr<'_>| {
let ty = cx.tables.expr_ty(assignee);
let rty = cx.tables.expr_ty(rhs);

View File

@ -22,7 +22,7 @@ declare_clippy_lint! {
///
/// **Example:** No. You'll see it when you get the warning.
pub COGNITIVE_COMPLEXITY,
complexity,
nursery,
"functions that should be split up into multiple functions"
}

View File

@ -1174,7 +1174,6 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
LintId::of(&booleans::LOGIC_BUG),
LintId::of(&booleans::NONMINIMAL_BOOL),
LintId::of(&bytecount::NAIVE_BYTECOUNT),
LintId::of(&cognitive_complexity::COGNITIVE_COMPLEXITY),
LintId::of(&collapsible_if::COLLAPSIBLE_IF),
LintId::of(&comparison_chain::COMPARISON_CHAIN),
LintId::of(&copies::IFS_SAME_COND),
@ -1509,7 +1508,6 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
LintId::of(&assign_ops::MISREFACTORED_ASSIGN_OP),
LintId::of(&attrs::DEPRECATED_CFG_ATTR),
LintId::of(&booleans::NONMINIMAL_BOOL),
LintId::of(&cognitive_complexity::COGNITIVE_COMPLEXITY),
LintId::of(&double_comparison::DOUBLE_COMPARISONS),
LintId::of(&double_parens::DOUBLE_PARENS),
LintId::of(&duration_subsec::DURATION_SUBSEC),
@ -1678,6 +1676,7 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
store.register_group(true, "clippy::nursery", Some("clippy_nursery"), vec![
LintId::of(&attrs::EMPTY_LINE_AFTER_OUTER_ATTR),
LintId::of(&cognitive_complexity::COGNITIVE_COMPLEXITY),
LintId::of(&fallible_impl_from::FALLIBLE_IMPL_FROM),
LintId::of(&floating_point_arithmetic::IMPRECISE_FLOPS),
LintId::of(&floating_point_arithmetic::SUBOPTIMAL_FLOPS),

View File

@ -1317,7 +1317,7 @@ declare_lint_pass!(Methods => [
]);
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Methods {
#[allow(clippy::cognitive_complexity, clippy::too_many_lines)]
#[allow(clippy::too_many_lines)]
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx hir::Expr<'_>) {
if in_macro(expr.span) {
return;

View File

@ -53,7 +53,6 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for DebugAssertWithMutCall {
}
//HACK(hellow554): remove this when #4694 is implemented
#[allow(clippy::cognitive_complexity)]
fn extract_call<'a, 'tcx>(cx: &'a LateContext<'a, 'tcx>, e: &'tcx Expr<'_>) -> Option<Span> {
if_chain! {
if let ExprKind::Block(ref block, _) = e.kind;

View File

@ -315,7 +315,6 @@ impl Types {
/// The parameter `is_local` distinguishes the context of the type; types from
/// local bindings should only be checked for the `BORROWED_BOX` lint.
#[allow(clippy::too_many_lines)]
#[allow(clippy::cognitive_complexity)]
fn check_ty(&mut self, cx: &LateContext<'_, '_>, hir_ty: &hir::Ty<'_>, is_local: bool) {
if hir_ty.span.from_expansion() {
return;

View File

@ -250,7 +250,7 @@ pub static ref ALL_LINTS: Vec<Lint> = vec![
},
Lint {
name: "cognitive_complexity",
group: "complexity",
group: "nursery",
desc: "functions that should be split up into multiple functions",
deprecation: None,
module: "cognitive_complexity",

View File

@ -1,5 +1,5 @@
// run-rustfix
#![allow(clippy::cognitive_complexity, clippy::assertions_on_constants)]
#![allow(clippy::assertions_on_constants)]
#[rustfmt::skip]
#[warn(clippy::collapsible_if)]

View File

@ -1,5 +1,5 @@
// run-rustfix
#![allow(clippy::cognitive_complexity, clippy::assertions_on_constants)]
#![allow(clippy::assertions_on_constants)]
#[rustfmt::skip]
#[warn(clippy::collapsible_if)]

View File

@ -1,5 +1,5 @@
// run-rustfix
#![allow(clippy::cognitive_complexity, clippy::assertions_on_constants)]
#![allow(clippy::assertions_on_constants)]
#[rustfmt::skip]
#[warn(clippy::collapsible_if)]

View File

@ -1,5 +1,5 @@
// run-rustfix
#![allow(clippy::cognitive_complexity, clippy::assertions_on_constants)]
#![allow(clippy::assertions_on_constants)]
#[rustfmt::skip]
#[warn(clippy::collapsible_if)]

View File

@ -2,7 +2,7 @@
#![feature(custom_inner_attributes)]
#![rustfmt::skip]
#![warn(clippy::debug_assert_with_mut_call)]
#![allow(clippy::cognitive_complexity, clippy::redundant_closure_call)]
#![allow(clippy::redundant_closure_call)]
struct S;

View File

@ -28,7 +28,6 @@ impl Unrelated {
clippy::linkedlist,
clippy::shadow_unrelated,
clippy::unnecessary_mut_passed,
clippy::cognitive_complexity,
clippy::similar_names
)]
#[allow(clippy::many_single_char_names, unused_variables)]

View File

@ -28,7 +28,6 @@ impl Unrelated {
clippy::linkedlist,
clippy::shadow_unrelated,
clippy::unnecessary_mut_passed,
clippy::cognitive_complexity,
clippy::similar_names
)]
#[allow(clippy::many_single_char_names, unused_variables)]

View File

@ -1,5 +1,5 @@
error: this range is empty so this for loop will never run
--> $DIR/for_loop_fixable.rs:39:14
--> $DIR/for_loop_fixable.rs:38:14
|
LL | for i in 10..0 {
| ^^^^^
@ -11,7 +11,7 @@ LL | for i in (0..10).rev() {
| ^^^^^^^^^^^^^
error: this range is empty so this for loop will never run
--> $DIR/for_loop_fixable.rs:43:14
--> $DIR/for_loop_fixable.rs:42:14
|
LL | for i in 10..=0 {
| ^^^^^^
@ -22,7 +22,7 @@ LL | for i in (0..=10).rev() {
| ^^^^^^^^^^^^^^
error: this range is empty so this for loop will never run
--> $DIR/for_loop_fixable.rs:47:14
--> $DIR/for_loop_fixable.rs:46:14
|
LL | for i in MAX_LEN..0 {
| ^^^^^^^^^^
@ -33,7 +33,7 @@ LL | for i in (0..MAX_LEN).rev() {
| ^^^^^^^^^^^^^^^^^^
error: this range is empty so this for loop will never run
--> $DIR/for_loop_fixable.rs:72:14
--> $DIR/for_loop_fixable.rs:71:14
|
LL | for i in 10..5 + 4 {
| ^^^^^^^^^
@ -44,7 +44,7 @@ LL | for i in (5 + 4..10).rev() {
| ^^^^^^^^^^^^^^^^^
error: this range is empty so this for loop will never run
--> $DIR/for_loop_fixable.rs:76:14
--> $DIR/for_loop_fixable.rs:75:14
|
LL | for i in (5 + 2)..(3 - 1) {
| ^^^^^^^^^^^^^^^^
@ -55,7 +55,7 @@ LL | for i in ((3 - 1)..(5 + 2)).rev() {
| ^^^^^^^^^^^^^^^^^^^^^^^^
error: it is more concise to loop over references to containers instead of using explicit iteration methods
--> $DIR/for_loop_fixable.rs:98:15
--> $DIR/for_loop_fixable.rs:97:15
|
LL | for _v in vec.iter() {}
| ^^^^^^^^^^ help: to write this more concisely, try: `&vec`
@ -63,13 +63,13 @@ LL | for _v in vec.iter() {}
= note: `-D clippy::explicit-iter-loop` implied by `-D warnings`
error: it is more concise to loop over references to containers instead of using explicit iteration methods
--> $DIR/for_loop_fixable.rs:100:15
--> $DIR/for_loop_fixable.rs:99:15
|
LL | for _v in vec.iter_mut() {}
| ^^^^^^^^^^^^^^ help: to write this more concisely, try: `&mut vec`
error: it is more concise to loop over containers instead of using explicit iteration methods
--> $DIR/for_loop_fixable.rs:103:15
--> $DIR/for_loop_fixable.rs:102:15
|
LL | for _v in out_vec.into_iter() {}
| ^^^^^^^^^^^^^^^^^^^ help: to write this more concisely, try: `out_vec`
@ -77,73 +77,73 @@ LL | for _v in out_vec.into_iter() {}
= note: `-D clippy::explicit-into-iter-loop` implied by `-D warnings`
error: it is more concise to loop over references to containers instead of using explicit iteration methods
--> $DIR/for_loop_fixable.rs:108:15
--> $DIR/for_loop_fixable.rs:107:15
|
LL | for _v in [1, 2, 3].iter() {}
| ^^^^^^^^^^^^^^^^ help: to write this more concisely, try: `&[1, 2, 3]`
error: it is more concise to loop over references to containers instead of using explicit iteration methods
--> $DIR/for_loop_fixable.rs:112:15
--> $DIR/for_loop_fixable.rs:111:15
|
LL | for _v in [0; 32].iter() {}
| ^^^^^^^^^^^^^^ help: to write this more concisely, try: `&[0; 32]`
error: it is more concise to loop over references to containers instead of using explicit iteration methods
--> $DIR/for_loop_fixable.rs:117:15
--> $DIR/for_loop_fixable.rs:116:15
|
LL | for _v in ll.iter() {}
| ^^^^^^^^^ help: to write this more concisely, try: `&ll`
error: it is more concise to loop over references to containers instead of using explicit iteration methods
--> $DIR/for_loop_fixable.rs:120:15
--> $DIR/for_loop_fixable.rs:119:15
|
LL | for _v in vd.iter() {}
| ^^^^^^^^^ help: to write this more concisely, try: `&vd`
error: it is more concise to loop over references to containers instead of using explicit iteration methods
--> $DIR/for_loop_fixable.rs:123:15
--> $DIR/for_loop_fixable.rs:122:15
|
LL | for _v in bh.iter() {}
| ^^^^^^^^^ help: to write this more concisely, try: `&bh`
error: it is more concise to loop over references to containers instead of using explicit iteration methods
--> $DIR/for_loop_fixable.rs:126:15
--> $DIR/for_loop_fixable.rs:125:15
|
LL | for _v in hm.iter() {}
| ^^^^^^^^^ help: to write this more concisely, try: `&hm`
error: it is more concise to loop over references to containers instead of using explicit iteration methods
--> $DIR/for_loop_fixable.rs:129:15
--> $DIR/for_loop_fixable.rs:128:15
|
LL | for _v in bt.iter() {}
| ^^^^^^^^^ help: to write this more concisely, try: `&bt`
error: it is more concise to loop over references to containers instead of using explicit iteration methods
--> $DIR/for_loop_fixable.rs:132:15
--> $DIR/for_loop_fixable.rs:131:15
|
LL | for _v in hs.iter() {}
| ^^^^^^^^^ help: to write this more concisely, try: `&hs`
error: it is more concise to loop over references to containers instead of using explicit iteration methods
--> $DIR/for_loop_fixable.rs:135:15
--> $DIR/for_loop_fixable.rs:134:15
|
LL | for _v in bs.iter() {}
| ^^^^^^^^^ help: to write this more concisely, try: `&bs`
error: it is more concise to loop over containers instead of using explicit iteration methods
--> $DIR/for_loop_fixable.rs:310:18
--> $DIR/for_loop_fixable.rs:309:18
|
LL | for i in iterator.into_iter() {
| ^^^^^^^^^^^^^^^^^^^^ help: to write this more concisely, try: `iterator`
error: it is more concise to loop over references to containers instead of using explicit iteration methods
--> $DIR/for_loop_fixable.rs:330:18
--> $DIR/for_loop_fixable.rs:329:18
|
LL | for _ in t.into_iter() {}
| ^^^^^^^^^^^^^ help: to write this more concisely, try: `&t`
error: it is more concise to loop over containers instead of using explicit iteration methods
--> $DIR/for_loop_fixable.rs:332:18
--> $DIR/for_loop_fixable.rs:331:18
|
LL | for _ in r.into_iter() {}
| ^^^^^^^^^^^^^ help: to write this more concisely, try: `r`

View File

@ -12,7 +12,6 @@
clippy::linkedlist,
clippy::shadow_unrelated,
clippy::unnecessary_mut_passed,
clippy::cognitive_complexity,
clippy::similar_names,
unused,
dead_code

View File

@ -1,5 +1,5 @@
error[E0425]: cannot find function `f` in this scope
--> $DIR/for_loop_unfixable.rs:37:12
--> $DIR/for_loop_unfixable.rs:36:12
|
LL | if f(&vec[i], &vec[i]) {
| ^ help: a local variable with a similar name exists: `i`

View File

@ -1,7 +1,6 @@
#![warn(clippy::if_same_then_else)]
#![allow(
clippy::blacklisted_name,
clippy::cognitive_complexity,
clippy::collapsible_if,
clippy::ifs_same_cond,
clippy::needless_return

View File

@ -1,5 +1,5 @@
error: this `if` has identical blocks
--> $DIR/if_same_then_else2.rs:20:12
--> $DIR/if_same_then_else2.rs:19:12
|
LL | } else {
| ____________^
@ -13,7 +13,7 @@ LL | | }
|
= note: `-D clippy::if-same-then-else` implied by `-D warnings`
note: same as this
--> $DIR/if_same_then_else2.rs:11:13
--> $DIR/if_same_then_else2.rs:10:13
|
LL | if true {
| _____________^
@ -26,7 +26,7 @@ LL | | } else {
| |_____^
error: this `if` has identical blocks
--> $DIR/if_same_then_else2.rs:34:12
--> $DIR/if_same_then_else2.rs:33:12
|
LL | } else {
| ____________^
@ -36,7 +36,7 @@ LL | | }
| |_____^
|
note: same as this
--> $DIR/if_same_then_else2.rs:32:13
--> $DIR/if_same_then_else2.rs:31:13
|
LL | if true {
| _____________^
@ -45,7 +45,7 @@ LL | | } else {
| |_____^
error: this `if` has identical blocks
--> $DIR/if_same_then_else2.rs:41:12
--> $DIR/if_same_then_else2.rs:40:12
|
LL | } else {
| ____________^
@ -55,7 +55,7 @@ LL | | }
| |_____^
|
note: same as this
--> $DIR/if_same_then_else2.rs:39:13
--> $DIR/if_same_then_else2.rs:38:13
|
LL | if true {
| _____________^
@ -64,7 +64,7 @@ LL | | } else {
| |_____^
error: this `if` has identical blocks
--> $DIR/if_same_then_else2.rs:91:12
--> $DIR/if_same_then_else2.rs:90:12
|
LL | } else {
| ____________^
@ -74,7 +74,7 @@ LL | | };
| |_____^
|
note: same as this
--> $DIR/if_same_then_else2.rs:89:21
--> $DIR/if_same_then_else2.rs:88:21
|
LL | let _ = if true {
| _____________________^
@ -83,7 +83,7 @@ LL | | } else {
| |_____^
error: this `if` has identical blocks
--> $DIR/if_same_then_else2.rs:98:12
--> $DIR/if_same_then_else2.rs:97:12
|
LL | } else {
| ____________^
@ -93,7 +93,7 @@ LL | | }
| |_____^
|
note: same as this
--> $DIR/if_same_then_else2.rs:96:13
--> $DIR/if_same_then_else2.rs:95:13
|
LL | if true {
| _____________^
@ -102,7 +102,7 @@ LL | | } else {
| |_____^
error: this `if` has identical blocks
--> $DIR/if_same_then_else2.rs:123:12
--> $DIR/if_same_then_else2.rs:122:12
|
LL | } else {
| ____________^
@ -112,7 +112,7 @@ LL | | }
| |_____^
|
note: same as this
--> $DIR/if_same_then_else2.rs:120:20
--> $DIR/if_same_then_else2.rs:119:20
|
LL | } else if true {
| ____________________^

View File

@ -5,7 +5,6 @@
// allow the new lint name here, to test if the new name works
#![allow(clippy::module_name_repetitions)]
#![allow(clippy::new_without_default)]
#![allow(clippy::cognitive_complexity)]
#![allow(clippy::redundant_static_lifetimes)]
// warn for the old lint name here, to test if the renaming worked
#![warn(clippy::cognitive_complexity)]

View File

@ -5,7 +5,6 @@
// allow the new lint name here, to test if the new name works
#![allow(clippy::module_name_repetitions)]
#![allow(clippy::new_without_default)]
#![allow(clippy::cognitive_complexity)]
#![allow(clippy::redundant_static_lifetimes)]
// warn for the old lint name here, to test if the renaming worked
#![warn(clippy::cyclomatic_complexity)]

View File

@ -1,5 +1,5 @@
error: lint `clippy::cyclomatic_complexity` has been renamed to `clippy::cognitive_complexity`
--> $DIR/rename.rs:11:9
--> $DIR/rename.rs:10:9
|
LL | #![warn(clippy::cyclomatic_complexity)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::cognitive_complexity`
@ -7,25 +7,25 @@ LL | #![warn(clippy::cyclomatic_complexity)]
= note: `-D renamed-and-removed-lints` implied by `-D warnings`
error: lint `clippy::stutter` has been renamed to `clippy::module_name_repetitions`
--> $DIR/rename.rs:13:8
--> $DIR/rename.rs:12:8
|
LL | #[warn(clippy::stutter)]
| ^^^^^^^^^^^^^^^ help: use the new name: `clippy::module_name_repetitions`
error: lint `clippy::new_without_default_derive` has been renamed to `clippy::new_without_default`
--> $DIR/rename.rs:16:8
--> $DIR/rename.rs:15:8
|
LL | #[warn(clippy::new_without_default_derive)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::new_without_default`
error: lint `clippy::const_static_lifetime` has been renamed to `clippy::redundant_static_lifetimes`
--> $DIR/rename.rs:19:8
--> $DIR/rename.rs:18:8
|
LL | #[warn(clippy::const_static_lifetime)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::redundant_static_lifetimes`
error: lint `clippy::cyclomatic_complexity` has been renamed to `clippy::cognitive_complexity`
--> $DIR/rename.rs:11:9
--> $DIR/rename.rs:10:9
|
LL | #![warn(clippy::cyclomatic_complexity)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::cognitive_complexity`

View File

@ -1,5 +1,5 @@
#![warn(clippy::while_let_on_iterator)]
#![allow(clippy::never_loop, clippy::cognitive_complexity)]
#![allow(clippy::never_loop)]
fn main() {
let mut iter = 1..20;