@@ -4,6 +4,7 @@ use clippy_utils::source::{IntoSpan, SpanRangeExt};
4
4
use clippy_utils:: ty:: is_type_diagnostic_item;
5
5
use clippy_utils:: visitors:: for_each_expr_without_closures;
6
6
use clippy_utils:: { get_async_fn_body, is_async_fn, LimitStack } ;
7
+ use rustc_lint:: { Level :: Allow , Lint } ;
7
8
use core:: ops:: ControlFlow ;
8
9
use rustc_ast:: ast:: Attribute ;
9
10
use rustc_hir:: intravisit:: FnKind ;
@@ -13,25 +14,62 @@ use rustc_session::impl_lint_pass;
13
14
use rustc_span:: def_id:: LocalDefId ;
14
15
use rustc_span:: { sym, Span } ;
15
16
16
- declare_clippy_lint ! {
17
- /// ### What it does
18
- /// Checks for methods with high cognitive complexity.
19
- ///
20
- /// ### Why is this bad?
21
- /// Methods of high cognitive complexity tend to be hard to
22
- /// both read and maintain. Also LLVM will tend to optimize small methods better.
23
- ///
24
- /// ### Known problems
25
- /// Sometimes it's hard to find a way to reduce the
26
- /// complexity.
27
- ///
28
- /// ### Example
29
- /// You'll see it when you get the warning.
30
- #[ clippy:: version = "1.35.0" ]
31
- pub COGNITIVE_COMPLEXITY ,
32
- nursery,
33
- "functions that should be split up into multiple functions"
34
- }
17
+ use crate :: LintInfo ;
18
+
19
+ // declare_clippy_lint! {
20
+ // /// ### What it does
21
+ // /// Checks for methods with high cognitive complexity.
22
+ // ///
23
+ // /// ### Why is this bad?
24
+ // /// Methods of high cognitive complexity tend to be hard to
25
+ // /// both read and maintain. Also LLVM will tend to optimize small methods better.
26
+ // ///
27
+ // /// ### Known problems
28
+ // /// Sometimes it's hard to find a way to reduce the
29
+ // /// complexity.
30
+ // ///
31
+ // /// ### Example
32
+ // /// You'll see it when you get the warning.
33
+ // #[clippy::version = "1.35.0"]
34
+ // pub COGNITIVE_COMPLEXITY,
35
+ // nursery,
36
+ // "functions that should be split up into multiple functions"
37
+ // }
38
+
39
+ // Recursive expansion of declare_clippy_lint! macro
40
+ // ==================================================
41
+
42
+ #[ doc = " ### What it does" ]
43
+ #[ doc = " Checks for methods with high cognitive complexity." ]
44
+ #[ doc = "" ]
45
+ #[ doc = " ### Why is this bad?" ]
46
+ #[ doc = " Methods of high cognitive complexity tend to be hard to" ]
47
+ #[ doc = " both read and maintain. Also LLVM will tend to optimize small methods better." ]
48
+ #[ doc = "" ]
49
+ #[ doc = " ### Known problems" ]
50
+ #[ doc = " Sometimes it\' s hard to find a way to reduce the" ]
51
+ #[ doc = " complexity." ]
52
+ #[ doc = "" ]
53
+ #[ doc = " ### Example" ]
54
+ #[ doc = " You\' ll see it when you get the warning." ]
55
+ #[ clippy:: version = "1.35.0" ]
56
+ pub static COGNITIVE_COMPLEXITY : & Lint = & Lint {
57
+ name : & "clippy::COGNITIVE_COMPLEXITY" ,
58
+ default_level : Allow ,
59
+ desc : "functions that should be split up into multiple functions" ,
60
+ edition_lint_opts : None ,
61
+ report_in_external_macro : true ,
62
+ future_incompatible : None ,
63
+ is_externally_loaded : true ,
64
+ crate_level_only : false ,
65
+ loadbearing : true ,
66
+ ..Lint :: default_fields_for_macro ( )
67
+ } ;
68
+ pub ( crate ) static COGNITIVE_COMPLEXITY_INFO : & ' static LintInfo = & LintInfo {
69
+ lint : & COGNITIVE_COMPLEXITY ,
70
+ category : crate :: LintCategory :: Nursery ,
71
+ explanation : "### What it does\n Checks for methods with high cognitive complexity.\n \n ### Why is this bad?\n Methods of high cognitive complexity tend to be hard to\n both read and maintain. Also LLVM will tend to optimize small methods better.\n \n ### Known problems\n Sometimes it's hard to find a way to reduce the\n complexity.\n \n ### Example\n You'll see it when you get the warning.\n " ,
72
+ } ;
35
73
36
74
pub struct CognitiveComplexity {
37
75
limit : LimitStack ,
0 commit comments