Skip to content

Commit 78f94e2

Browse files
committed
rename to excessive_nesting and remove excessive_width completely
1 parent ce2c4dd commit 78f94e2

File tree

12 files changed

+27
-236
lines changed

12 files changed

+27
-236
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4630,7 +4630,7 @@ Released 2018-09-13
46304630
[`erasing_op`]: https://rust-lang.github.io/rust-clippy/master/index.html#erasing_op
46314631
[`err_expect`]: https://rust-lang.github.io/rust-clippy/master/index.html#err_expect
46324632
[`eval_order_dependence`]: https://rust-lang.github.io/rust-clippy/master/index.html#eval_order_dependence
4633-
[`excessive_indentation`]: https://rust-lang.github.io/rust-clippy/master/index.html#excessive_indentation
4633+
[`excessive_nesting`]: https://rust-lang.github.io/rust-clippy/master/index.html#excessive_nesting
46344634
[`excessive_precision`]: https://rust-lang.github.io/rust-clippy/master/index.html#excessive_precision
46354635
[`exhaustive_enums`]: https://rust-lang.github.io/rust-clippy/master/index.html#exhaustive_enums
46364636
[`exhaustive_structs`]: https://rust-lang.github.io/rust-clippy/master/index.html#exhaustive_structs

clippy_lints/src/declared_lints.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ pub(crate) static LINTS: &[&crate::LintInfo] = &[
154154
crate::eta_reduction::REDUNDANT_CLOSURE_FOR_METHOD_CALLS_INFO,
155155
crate::excessive_bools::FN_PARAMS_EXCESSIVE_BOOLS_INFO,
156156
crate::excessive_bools::STRUCT_EXCESSIVE_BOOLS_INFO,
157-
crate::excessive_indentation::EXCESSIVE_INDENTATION_INFO,
157+
crate::excessive_nesting::EXCESSIVE_NESTING_INFO,
158158
crate::exhaustive_items::EXHAUSTIVE_ENUMS_INFO,
159159
crate::exhaustive_items::EXHAUSTIVE_STRUCTS_INFO,
160160
crate::exit::EXIT_INFO,

clippy_lints/src/excessive_indentation.rs renamed to clippy_lints/src/excessive_nesting.rs

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use thin_vec::ThinVec;
1616
declare_clippy_lint! {
1717
/// ### What it does
1818
///
19-
/// Checks for lines which are indented beyond a certain threshold.
19+
/// Checks for blocks which are indented beyond a certain threshold.
2020
///
2121
/// ### Why is this bad?
2222
///
@@ -28,45 +28,43 @@ declare_clippy_lint! {
2828
/// Use instead:
2929
/// TODO
3030
#[clippy::version = "1.70.0"]
31-
pub EXCESSIVE_INDENTATION,
31+
pub EXCESSIVE_NESTING,
3232
nursery,
33-
"checks for lines indented beyond a certain threshold"
33+
"checks for blocks nested beyond a certain threshold"
3434
}
35-
impl_lint_pass!(ExcessiveIndentation => [EXCESSIVE_INDENTATION]);
35+
impl_lint_pass!(ExcessiveNesting => [EXCESSIVE_NESTING]);
3636

3737
#[derive(Clone, Copy)]
38-
pub struct ExcessiveIndentation {
39-
pub excessive_width_threshold: u64,
40-
pub excessive_width_ignore_indentation: bool,
41-
pub excessive_indentation_threshold: u64,
38+
pub struct ExcessiveNesting {
39+
pub excessive_nesting_threshold: u64,
4240
}
4341

44-
impl EarlyLintPass for ExcessiveIndentation {
42+
impl EarlyLintPass for ExcessiveNesting {
4543
fn check_item(&mut self, cx: &EarlyContext<'_>, item: &Item) {
46-
IndentationVisitor { indent: 0 }.visit_item(item);
44+
NestingVisitor { indent: 0 }.visit_item(item);
4745
}
4846
}
4947

5048
/// RAII guard to add 1 to our indent counter when constructed, and remove 1 when dropped.
51-
struct IndentationGuard<'i>(&'i mut u64);
49+
struct NestingGuard<'i>(&'i mut u64);
5250

53-
impl<'i> IndentationGuard<'i> {
51+
impl<'i> NestingGuard<'i> {
5452
fn new(indent: &'i mut u64) -> Self {
5553
Self(indent)
5654
}
5755
}
5856

59-
impl<'i> Drop for IndentationGuard<'i> {
57+
impl<'i> Drop for NestingGuard<'i> {
6058
fn drop(&mut self) {
6159
*self.0 -= 1;
6260
}
6361
}
6462

65-
struct IndentationVisitor {
63+
struct NestingVisitor {
6664
indent: u64,
6765
}
6866

69-
impl Visitor<'_> for IndentationVisitor {
67+
impl Visitor<'_> for NestingVisitor {
7068
fn visit_foreign_item(&mut self, item: &ForeignItem) {
7169
match &item.kind {
7270
ForeignItemKind::Static(.., expr) => {
@@ -80,7 +78,7 @@ impl Visitor<'_> for IndentationVisitor {
8078
}
8179

8280
fn visit_block(&mut self, block: &Block) {
83-
IndentationGuard::new(&mut self.indent);
81+
NestingGuard::new(&mut self.indent);
8482

8583
todo!();
8684
}
@@ -122,7 +120,7 @@ impl Visitor<'_> for IndentationVisitor {
122120
}
123121

124122
fn visit_fn(&mut self, fk: FnKind<'_>, _: Span, _: NodeId) {
125-
IndentationGuard::new(&mut self.indent);
123+
NestingGuard::new(&mut self.indent);
126124

127125
match fk {
128126
FnKind::Fn(.., block) if let Some(block) = block => self.visit_block(block),
@@ -134,7 +132,7 @@ impl Visitor<'_> for IndentationVisitor {
134132
fn visit_use_tree(&mut self, use_tree: &UseTree, _: NodeId, _: bool) {
135133
// TODO: I don't think this should be linted, as some devious crate may decide to put some type
136134
// nested within 10 modules. Maybe it can be optional using config?
137-
IndentationGuard::new(&mut self.indent);
135+
NestingGuard::new(&mut self.indent);
138136

139137
if let UseTreeKind::Nested(use_trees) = &use_tree.kind {
140138
for use_tree in use_trees {

clippy_lints/src/lib.rs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ mod equatable_if_let;
120120
mod escape;
121121
mod eta_reduction;
122122
mod excessive_bools;
123-
mod excessive_indentation;
123+
mod excessive_nesting;
124124
mod exhaustive_items;
125125
mod exit;
126126
mod explicit_write;
@@ -963,14 +963,10 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
963963
store.register_late_pass(|_| Box::new(tests_outside_test_module::TestsOutsideTestModule));
964964
store.register_late_pass(|_| Box::new(manual_slice_size_calculation::ManualSliceSizeCalculation));
965965
store.register_early_pass(|| Box::new(suspicious_doc_comments::SuspiciousDocComments));
966-
let excessive_width_threshold = conf.excessive_width_threshold;
967-
let excessive_width_ignore_indentation = conf.excessive_width_ignore_indentation;
968-
let excessive_indentation_threshold = conf.excessive_indentation_threshold;
969-
store.register_late_pass(move |_| {
970-
Box::new(excessive_indentation::ExcessiveIndentation {
971-
excessive_width_threshold,
972-
excessive_width_ignore_indentation,
973-
excessive_indentation_threshold,
966+
let excessive_nesting_threshold = conf.excessive_nesting_threshold;
967+
store.register_early_pass(move || {
968+
Box::new(excessive_nesting::ExcessiveNesting {
969+
excessive_nesting_threshold,
974970
})
975971
});
976972
store.register_late_pass(|_| Box::new(items_after_test_module::ItemsAfterTestModule));

clippy_lints/src/utils/conf.rs

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -266,18 +266,10 @@ define_Conf! {
266266
///
267267
/// The maximum cognitive complexity a function can have
268268
(cognitive_complexity_threshold: u64 = 25),
269-
/// Lint: EXCESSIVE_WIDTH.
269+
/// Lint: EXCESSIVE_NESTING.
270270
///
271-
/// The maximum width a statement can have
272-
(excessive_width_threshold: u64 = 100),
273-
/// Lint: EXCESSIVE_WIDTH.
274-
///
275-
/// Whether to ignore the line's indentation
276-
(excessive_width_ignore_indentation: bool = true),
277-
/// Lint: EXCESSIVE_INDENTATION.
278-
///
279-
/// The maximum indentation a statement can have
280-
(excessive_indentation_threshold: u64 = 10),
271+
/// The maximum amount of nesting a block can reside in
272+
(excessive_nesting_threshold: u64 = 10),
281273
/// DEPRECATED LINT: CYCLOMATIC_COMPLEXITY.
282274
///
283275
/// Use the Cognitive Complexity lint instead.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
excessive-nesting-threshold = 3

tests/ui-toml/excessive_width/clippy.toml

Lines changed: 0 additions & 3 deletions
This file was deleted.

tests/ui-toml/excessive_width/excessive_width.rs

Lines changed: 0 additions & 26 deletions
This file was deleted.

tests/ui-toml/excessive_width/excessive_width.stderr

Lines changed: 0 additions & 24 deletions
This file was deleted.

0 commit comments

Comments
 (0)