Skip to content

Commit 7bfdee5

Browse files
committed
Auto merge of #5428 - dtolnay:cognitive, r=flip1995
Move cognitive_complexity to nursery As discussed in #5418 (comment); Clippy's current understanding of cognitive complexity is not good enough yet at analyzing code for understandability to have this lint be enabled by default. changelog: Remove cognitive_complexity from default set of enabled lints
2 parents f8308c8 + 899a1b5 commit 7bfdee5

23 files changed

+48
-58
lines changed

clippy_lints/src/assign_ops.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for AssignOps {
7777
},
7878
hir::ExprKind::Assign(assignee, e, _) => {
7979
if let hir::ExprKind::Binary(op, l, r) = &e.kind {
80-
#[allow(clippy::cognitive_complexity)]
8180
let lint = |assignee: &hir::Expr<'_>, rhs: &hir::Expr<'_>| {
8281
let ty = cx.tables.expr_ty(assignee);
8382
let rty = cx.tables.expr_ty(rhs);

clippy_lints/src/cognitive_complexity.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ declare_clippy_lint! {
2222
///
2323
/// **Example:** No. You'll see it when you get the warning.
2424
pub COGNITIVE_COMPLEXITY,
25-
complexity,
25+
nursery,
2626
"functions that should be split up into multiple functions"
2727
}
2828

clippy_lints/src/lib.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1174,7 +1174,6 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
11741174
LintId::of(&booleans::LOGIC_BUG),
11751175
LintId::of(&booleans::NONMINIMAL_BOOL),
11761176
LintId::of(&bytecount::NAIVE_BYTECOUNT),
1177-
LintId::of(&cognitive_complexity::COGNITIVE_COMPLEXITY),
11781177
LintId::of(&collapsible_if::COLLAPSIBLE_IF),
11791178
LintId::of(&comparison_chain::COMPARISON_CHAIN),
11801179
LintId::of(&copies::IFS_SAME_COND),
@@ -1509,7 +1508,6 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
15091508
LintId::of(&assign_ops::MISREFACTORED_ASSIGN_OP),
15101509
LintId::of(&attrs::DEPRECATED_CFG_ATTR),
15111510
LintId::of(&booleans::NONMINIMAL_BOOL),
1512-
LintId::of(&cognitive_complexity::COGNITIVE_COMPLEXITY),
15131511
LintId::of(&double_comparison::DOUBLE_COMPARISONS),
15141512
LintId::of(&double_parens::DOUBLE_PARENS),
15151513
LintId::of(&duration_subsec::DURATION_SUBSEC),
@@ -1678,6 +1676,7 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
16781676

16791677
store.register_group(true, "clippy::nursery", Some("clippy_nursery"), vec![
16801678
LintId::of(&attrs::EMPTY_LINE_AFTER_OUTER_ATTR),
1679+
LintId::of(&cognitive_complexity::COGNITIVE_COMPLEXITY),
16811680
LintId::of(&fallible_impl_from::FALLIBLE_IMPL_FROM),
16821681
LintId::of(&floating_point_arithmetic::IMPRECISE_FLOPS),
16831682
LintId::of(&floating_point_arithmetic::SUBOPTIMAL_FLOPS),

clippy_lints/src/methods/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1317,7 +1317,7 @@ declare_lint_pass!(Methods => [
13171317
]);
13181318

13191319
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Methods {
1320-
#[allow(clippy::cognitive_complexity, clippy::too_many_lines)]
1320+
#[allow(clippy::too_many_lines)]
13211321
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx hir::Expr<'_>) {
13221322
if in_macro(expr.span) {
13231323
return;

clippy_lints/src/mutable_debug_assertion.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for DebugAssertWithMutCall {
5353
}
5454

5555
//HACK(hellow554): remove this when #4694 is implemented
56-
#[allow(clippy::cognitive_complexity)]
5756
fn extract_call<'a, 'tcx>(cx: &'a LateContext<'a, 'tcx>, e: &'tcx Expr<'_>) -> Option<Span> {
5857
if_chain! {
5958
if let ExprKind::Block(ref block, _) = e.kind;

clippy_lints/src/types.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,6 @@ impl Types {
315315
/// The parameter `is_local` distinguishes the context of the type; types from
316316
/// local bindings should only be checked for the `BORROWED_BOX` lint.
317317
#[allow(clippy::too_many_lines)]
318-
#[allow(clippy::cognitive_complexity)]
319318
fn check_ty(&mut self, cx: &LateContext<'_, '_>, hir_ty: &hir::Ty<'_>, is_local: bool) {
320319
if hir_ty.span.from_expansion() {
321320
return;

src/lintlist/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ pub static ref ALL_LINTS: Vec<Lint> = vec![
250250
},
251251
Lint {
252252
name: "cognitive_complexity",
253-
group: "complexity",
253+
group: "nursery",
254254
desc: "functions that should be split up into multiple functions",
255255
deprecation: None,
256256
module: "cognitive_complexity",

tests/ui/collapsible_else_if.fixed

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// run-rustfix
2-
#![allow(clippy::cognitive_complexity, clippy::assertions_on_constants)]
2+
#![allow(clippy::assertions_on_constants)]
33

44
#[rustfmt::skip]
55
#[warn(clippy::collapsible_if)]

tests/ui/collapsible_else_if.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// run-rustfix
2-
#![allow(clippy::cognitive_complexity, clippy::assertions_on_constants)]
2+
#![allow(clippy::assertions_on_constants)]
33

44
#[rustfmt::skip]
55
#[warn(clippy::collapsible_if)]

tests/ui/collapsible_if.fixed

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// run-rustfix
2-
#![allow(clippy::cognitive_complexity, clippy::assertions_on_constants)]
2+
#![allow(clippy::assertions_on_constants)]
33

44
#[rustfmt::skip]
55
#[warn(clippy::collapsible_if)]

0 commit comments

Comments
 (0)