Skip to content

Deprecate cognitive_complexity lint #15094

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6520,7 +6520,6 @@ Released 2018-09-13
[`check-incompatible-msrv-in-tests`]: https://doc.rust-lang.org/clippy/lint_configuration.html#check-incompatible-msrv-in-tests
[`check-inconsistent-struct-field-initializers`]: https://doc.rust-lang.org/clippy/lint_configuration.html#check-inconsistent-struct-field-initializers
[`check-private-items`]: https://doc.rust-lang.org/clippy/lint_configuration.html#check-private-items
[`cognitive-complexity-threshold`]: https://doc.rust-lang.org/clippy/lint_configuration.html#cognitive-complexity-threshold
[`disallowed-macros`]: https://doc.rust-lang.org/clippy/lint_configuration.html#disallowed-macros
[`disallowed-methods`]: https://doc.rust-lang.org/clippy/lint_configuration.html#disallowed-methods
[`disallowed-names`]: https://doc.rust-lang.org/clippy/lint_configuration.html#disallowed-names
Expand Down
10 changes: 0 additions & 10 deletions book/src/lint_configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -475,16 +475,6 @@ Whether to also run the listed lints on private items.
* [`unnecessary_safety_doc`](https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_safety_doc)


## `cognitive-complexity-threshold`
The maximum cognitive complexity a function can have

**Default Value:** `25`

---
**Affected lints:**
* [`cognitive_complexity`](https://rust-lang.github.io/rust-clippy/master/index.html#cognitive_complexity)


## `disallowed-macros`
The list of disallowed macros, written as fully qualified paths.

Expand Down
8 changes: 0 additions & 8 deletions clippy_config/src/conf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -566,14 +566,6 @@ define_Conf! {
/// Whether to also run the listed lints on private items.
#[lints(missing_errors_doc, missing_panics_doc, missing_safety_doc, unnecessary_safety_doc)]
check_private_items: bool = false,
/// The maximum cognitive complexity a function can have
#[lints(cognitive_complexity)]
cognitive_complexity_threshold: u64 = 25,
/// DEPRECATED LINT: CYCLOMATIC_COMPLEXITY.
///
/// Use the Cognitive Complexity lint instead.
#[conf_deprecated("Please use `cognitive-complexity-threshold` instead", cognitive_complexity_threshold)]
cyclomatic_complexity_threshold: u64 = 25,
/// The list of disallowed macros, written as fully qualified paths.
///
/// **Fields:**
Expand Down
165 changes: 0 additions & 165 deletions clippy_lints/src/cognitive_complexity.rs

This file was deleted.

1 change: 0 additions & 1 deletion clippy_lints/src/declared_lints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ pub static LINTS: &[&::declare_clippy_lint::LintInfo] = &[
crate::checked_conversions::CHECKED_CONVERSIONS_INFO,
crate::cloned_ref_to_slice_refs::CLONED_REF_TO_SLICE_REFS_INFO,
crate::coerce_container_to_any::COERCE_CONTAINER_TO_ANY_INFO,
crate::cognitive_complexity::COGNITIVE_COMPLEXITY_INFO,
crate::collapsible_if::COLLAPSIBLE_ELSE_IF_INFO,
crate::collapsible_if::COLLAPSIBLE_IF_INFO,
crate::collection_is_never_read::COLLECTION_IS_NEVER_READ_INFO,
Expand Down
6 changes: 4 additions & 2 deletions clippy_lints/src/deprecated_lints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ macro_rules! declare_with_version {
declare_with_version! { DEPRECATED(DEPRECATED_VERSION) = [
#[clippy::version = "1.30.0"]
("clippy::assign_ops", "compound operators are harmless and linting on them is not in scope for clippy"),
#[clippy::version = "1.90.0"]
("clippy::cognitive_complexity", "`excessive_nesting` and `too_many_lines` lints allow for finer-grain controls"),
#[clippy::version = "1.35.0"]
("clippy::cyclomatic_complexity", "`excessive_nesting` and `too_many_lines` lints allow for finer-grain controls"),
#[clippy::version = "pre 1.29.0"]
("clippy::extend_from_slice", "`Vec::extend_from_slice` is no longer faster than `Vec::extend` due to specialization"),
#[clippy::version = "1.86.0"]
Expand Down Expand Up @@ -69,8 +73,6 @@ declare_with_version! { RENAMED(RENAMED_VERSION) = [
#[clippy::version = ""]
("clippy::const_static_lifetime", "clippy::redundant_static_lifetimes"),
#[clippy::version = ""]
("clippy::cyclomatic_complexity", "clippy::cognitive_complexity"),
#[clippy::version = ""]
("clippy::derive_hash_xor_eq", "clippy::derived_hash_with_manual_eq"),
#[clippy::version = ""]
("clippy::disallowed_method", "clippy::disallowed_methods"),
Expand Down
2 changes: 0 additions & 2 deletions clippy_lints/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ mod cfg_not_test;
mod checked_conversions;
mod cloned_ref_to_slice_refs;
mod coerce_container_to_any;
mod cognitive_complexity;
mod collapsible_if;
mod collection_is_never_read;
mod comparison_chain;
Expand Down Expand Up @@ -537,7 +536,6 @@ pub fn register_lint_passes(store: &mut rustc_lint::LintStore, conf: &'static Co
store.register_late_pass(|_| Box::<no_effect::NoEffect>::default());
store.register_late_pass(|_| Box::new(temporary_assignment::TemporaryAssignment));
store.register_late_pass(move |_| Box::new(transmute::Transmute::new(conf)));
store.register_late_pass(move |_| Box::new(cognitive_complexity::CognitiveComplexity::new(conf)));
store.register_late_pass(move |_| Box::new(escape::BoxedLocal::new(conf)));
store.register_late_pass(move |_| Box::new(vec::UselessVec::new(conf)));
store.register_late_pass(move |_| Box::new(panic_unimplemented::PanicUnimplemented::new(conf)));
Expand Down
2 changes: 1 addition & 1 deletion tests/ui-toml/conf_deprecated_key/clippy.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Expect errors from these deprecated configs
cyclomatic-complexity-threshold = 2
blacklisted-names = [ "..", "wibble" ]
lint-inconsistent-struct-field-initializers = true

# that one is white-listed
[third-party]
Expand Down
13 changes: 1 addition & 12 deletions tests/ui-toml/conf_deprecated_key/conf_deprecated_key.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,3 @@
#![allow(clippy::uninlined_format_args)]
//@error-in-other-file:

fn main() {}

#[warn(clippy::cognitive_complexity)]
fn cognitive_complexity() {
//~^ cognitive_complexity
let x = vec![1, 2, 3];
for i in x {
if i == 1 {
println!("{}", i);
}
}
}
22 changes: 6 additions & 16 deletions tests/ui-toml/conf_deprecated_key/conf_deprecated_key.stderr
Original file line number Diff line number Diff line change
@@ -1,24 +1,14 @@
warning: error reading Clippy's configuration file: deprecated field `cyclomatic-complexity-threshold`. Please use `cognitive-complexity-threshold` instead
--> $DIR/tests/ui-toml/conf_deprecated_key/clippy.toml:2:1
|
LL | cyclomatic-complexity-threshold = 2
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

warning: error reading Clippy's configuration file: deprecated field `blacklisted-names`. Please use `disallowed-names` instead
--> $DIR/tests/ui-toml/conf_deprecated_key/clippy.toml:3:1
--> $DIR/tests/ui-toml/conf_deprecated_key/clippy.toml:2:1
|
LL | blacklisted-names = [ "..", "wibble" ]
| ^^^^^^^^^^^^^^^^^

error: the function has a cognitive complexity of (3/2)
--> tests/ui-toml/conf_deprecated_key/conf_deprecated_key.rs:6:4
|
LL | fn cognitive_complexity() {
| ^^^^^^^^^^^^^^^^^^^^
warning: error reading Clippy's configuration file: deprecated field `lint-inconsistent-struct-field-initializers`. Please use `check-inconsistent-struct-field-initializers` instead
--> $DIR/tests/ui-toml/conf_deprecated_key/clippy.toml:3:1
|
= help: you could split it up into multiple smaller functions
= note: `-D clippy::cognitive-complexity` implied by `-D warnings`
= help: to override `-D warnings` add `#[allow(clippy::cognitive_complexity)]`
LL | lint-inconsistent-struct-field-initializers = true
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: aborting due to 1 previous error; 2 warnings emitted
warning: 2 warnings emitted

4 changes: 2 additions & 2 deletions tests/ui-toml/duplicated_keys_deprecated/clippy.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
cognitive-complexity-threshold = 2
disallowed-names = ["core::panic"]
# This is the deprecated name for the same key
cyclomatic-complexity-threshold = 3
blacklisted-names = ["core::panic"]
12 changes: 6 additions & 6 deletions tests/ui-toml/duplicated_keys_deprecated/duplicated_keys.stderr
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
error: error reading Clippy's configuration file: duplicate field `cognitive_complexity_threshold` (provided as `cyclomatic_complexity_threshold`)
error: error reading Clippy's configuration file: duplicate field `disallowed_names` (provided as `blacklisted_names`)
--> $DIR/tests/ui-toml/duplicated_keys_deprecated/clippy.toml:3:1
|
LL | cyclomatic-complexity-threshold = 3
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
LL | blacklisted-names = ["core::panic"]
| ^^^^^^^^^^^^^^^^^

warning: error reading Clippy's configuration file: deprecated field `cyclomatic-complexity-threshold`. Please use `cognitive-complexity-threshold` instead
warning: error reading Clippy's configuration file: deprecated field `blacklisted-names`. Please use `disallowed-names` instead
--> $DIR/tests/ui-toml/duplicated_keys_deprecated/clippy.toml:3:1
|
LL | cyclomatic-complexity-threshold = 3
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
LL | blacklisted-names = ["core::panic"]
| ^^^^^^^^^^^^^^^^^

error: aborting due to 1 previous error; 1 warning emitted

6 changes: 3 additions & 3 deletions tests/ui-toml/duplicated_keys_deprecated_2/clippy.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# This is the deprecated name for cognitive-complexity-threshold
cyclomatic-complexity-threshold = 3
# This is the deprecated name for disallowed-names
blacklisted-names = ["core::panic"]
# Check we get duplication warning regardless of order
cognitive-complexity-threshold = 4
disallowed-names = ["core::panic"]
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
error: error reading Clippy's configuration file: duplicate field `cognitive-complexity-threshold`
error: error reading Clippy's configuration file: duplicate field `disallowed-names`
--> $DIR/tests/ui-toml/duplicated_keys_deprecated_2/clippy.toml:4:1
|
LL | cognitive-complexity-threshold = 4
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
LL | disallowed-names = ["core::panic"]
| ^^^^^^^^^^^^^^^^

warning: error reading Clippy's configuration file: deprecated field `cyclomatic-complexity-threshold`. Please use `cognitive-complexity-threshold` instead
warning: error reading Clippy's configuration file: deprecated field `blacklisted-names`. Please use `disallowed-names` instead
--> $DIR/tests/ui-toml/duplicated_keys_deprecated_2/clippy.toml:2:1
|
LL | cyclomatic-complexity-threshold = 3
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
LL | blacklisted-names = ["core::panic"]
| ^^^^^^^^^^^^^^^^^

error: aborting due to 1 previous error; 1 warning emitted

3 changes: 0 additions & 3 deletions tests/ui-toml/toml_unknown_key/conf_unknown_key.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ error: error reading Clippy's configuration file: unknown field `foobar`, expect
check-incompatible-msrv-in-tests
check-inconsistent-struct-field-initializers
check-private-items
cognitive-complexity-threshold
disallowed-macros
disallowed-methods
disallowed-names
Expand Down Expand Up @@ -128,7 +127,6 @@ error: error reading Clippy's configuration file: unknown field `barfoo`, expect
check-incompatible-msrv-in-tests
check-inconsistent-struct-field-initializers
check-private-items
cognitive-complexity-threshold
disallowed-macros
disallowed-methods
disallowed-names
Expand Down Expand Up @@ -222,7 +220,6 @@ error: error reading Clippy's configuration file: unknown field `allow_mixed_uni
check-incompatible-msrv-in-tests
check-inconsistent-struct-field-initializers
check-private-items
cognitive-complexity-threshold
disallowed-macros
disallowed-methods
disallowed-names
Expand Down
Loading