@@ -11,13 +11,12 @@ use rustc_span::Span;
11
11
12
12
declare_clippy_lint ! {
13
13
/// ### What it does
14
- ///
15
14
/// Checks for blocks which are nested beyond a certain threshold.
16
15
///
17
- /// ### Why is this bad?
16
+ /// Note: Even though this lint is warn-by-default, it will only trigger if a maximum nesting level is defined in the clippy.toml file.
18
17
///
19
- /// It can severely hinder readability. The default is very generous; if you
20
- /// exceed this, it's a sign you should refactor .
18
+ /// ### Why is this bad?
19
+ /// It can severely hinder readability .
21
20
///
22
21
/// ### Example
23
22
/// An example clippy.toml configuration:
@@ -59,7 +58,7 @@ declare_clippy_lint! {
59
58
/// ```
60
59
#[ clippy:: version = "1.70.0" ]
61
60
pub EXCESSIVE_NESTING ,
62
- restriction ,
61
+ complexity ,
63
62
"checks for blocks nested beyond a certain threshold"
64
63
}
65
64
impl_lint_pass ! ( ExcessiveNesting => [ EXCESSIVE_NESTING ] ) ;
@@ -115,7 +114,9 @@ struct NestingVisitor<'conf, 'cx> {
115
114
116
115
impl NestingVisitor < ' _ , ' _ > {
117
116
fn check_indent ( & mut self , span : Span , id : NodeId ) -> bool {
118
- if self . nest_level > self . conf . excessive_nesting_threshold && !in_external_macro ( self . cx . sess ( ) , span) {
117
+ let threshold = self . conf . excessive_nesting_threshold ;
118
+
119
+ if threshold != 0 && self . nest_level > threshold && !in_external_macro ( self . cx . sess ( ) , span) {
119
120
self . conf . nodes . insert ( id) ;
120
121
121
122
return true ;
0 commit comments