about summary refs log tree commit diff
path: root/src/tools/clippy/tests/ui/cognitive_complexity.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/tools/clippy/tests/ui/cognitive_complexity.rs')
-rw-r--r--src/tools/clippy/tests/ui/cognitive_complexity.rs20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/tools/clippy/tests/ui/cognitive_complexity.rs b/src/tools/clippy/tests/ui/cognitive_complexity.rs
index 07bdaff00dc..e8fd063a98f 100644
--- a/src/tools/clippy/tests/ui/cognitive_complexity.rs
+++ b/src/tools/clippy/tests/ui/cognitive_complexity.rs
@@ -4,6 +4,7 @@
 
 #[rustfmt::skip]
 fn main() {
+//~^ ERROR: the function has a cognitive complexity of (28/25)
     if true {
         println!("a");
     }
@@ -89,6 +90,7 @@ fn main() {
 
 #[clippy::cognitive_complexity = "1"]
 fn kaboom() {
+    //~^ ERROR: the function has a cognitive complexity of (7/1)
     let n = 0;
     'a: for i in 0..20 {
         'b: for j in i..20 {
@@ -147,7 +149,9 @@ fn lots_of_short_circuits2() -> bool {
 
 #[clippy::cognitive_complexity = "1"]
 fn baa() {
+    //~^ ERROR: the function has a cognitive complexity of (2/1)
     let x = || match 99 {
+        //~^ ERROR: the function has a cognitive complexity of (2/1)
         0 => 0,
         1 => 1,
         2 => 2,
@@ -165,6 +169,7 @@ fn baa() {
 
 #[clippy::cognitive_complexity = "1"]
 fn bar() {
+    //~^ ERROR: the function has a cognitive complexity of (2/1)
     match 99 {
         0 => println!("hi"),
         _ => println!("bye"),
@@ -176,6 +181,7 @@ fn bar() {
 /// Tests are usually complex but simple at the same time. `clippy::cognitive_complexity` used to
 /// give lots of false-positives in tests.
 fn dont_warn_on_tests() {
+    //~^ ERROR: the function has a cognitive complexity of (2/1)
     match 99 {
         0 => println!("hi"),
         _ => println!("bye"),
@@ -184,6 +190,7 @@ fn dont_warn_on_tests() {
 
 #[clippy::cognitive_complexity = "1"]
 fn barr() {
+    //~^ ERROR: the function has a cognitive complexity of (2/1)
     match 99 {
         0 => println!("hi"),
         1 => println!("bla"),
@@ -194,6 +201,7 @@ fn barr() {
 
 #[clippy::cognitive_complexity = "1"]
 fn barr2() {
+    //~^ ERROR: the function has a cognitive complexity of (3/1)
     match 99 {
         0 => println!("hi"),
         1 => println!("bla"),
@@ -210,6 +218,7 @@ fn barr2() {
 
 #[clippy::cognitive_complexity = "1"]
 fn barrr() {
+    //~^ ERROR: the function has a cognitive complexity of (2/1)
     match 99 {
         0 => println!("hi"),
         1 => panic!("bla"),
@@ -220,6 +229,7 @@ fn barrr() {
 
 #[clippy::cognitive_complexity = "1"]
 fn barrr2() {
+    //~^ ERROR: the function has a cognitive complexity of (3/1)
     match 99 {
         0 => println!("hi"),
         1 => panic!("bla"),
@@ -236,6 +246,7 @@ fn barrr2() {
 
 #[clippy::cognitive_complexity = "1"]
 fn barrrr() {
+    //~^ ERROR: the function has a cognitive complexity of (2/1)
     match 99 {
         0 => println!("hi"),
         1 => println!("bla"),
@@ -246,6 +257,7 @@ fn barrrr() {
 
 #[clippy::cognitive_complexity = "1"]
 fn barrrr2() {
+    //~^ ERROR: the function has a cognitive complexity of (3/1)
     match 99 {
         0 => println!("hi"),
         1 => println!("bla"),
@@ -262,6 +274,7 @@ fn barrrr2() {
 
 #[clippy::cognitive_complexity = "1"]
 fn cake() {
+    //~^ ERROR: the function has a cognitive complexity of (2/1)
     if 4 == 5 {
         println!("yea");
     } else {
@@ -272,6 +285,7 @@ fn cake() {
 
 #[clippy::cognitive_complexity = "1"]
 pub fn read_file(input_path: &str) -> String {
+    //~^ ERROR: the function has a cognitive complexity of (4/1)
     use std::fs::File;
     use std::io::{Read, Write};
     use std::path::Path;
@@ -303,6 +317,7 @@ enum Void {}
 
 #[clippy::cognitive_complexity = "1"]
 fn void(void: Void) {
+    //~^ ERROR: the function has a cognitive complexity of (2/1)
     if true {
         match void {}
     }
@@ -354,6 +369,7 @@ fn early() -> Result<i32, &'static str> {
 #[rustfmt::skip]
 #[clippy::cognitive_complexity = "1"]
 fn early_ret() -> i32 {
+//~^ ERROR: the function has a cognitive complexity of (8/1)
     let a = if true { 42 } else { return 0; };
     let a = if a < 99 { 42 } else { return 0; };
     let a = if a < 99 { 42 } else { return 0; };
@@ -375,6 +391,7 @@ fn early_ret() -> i32 {
 #[clippy::cognitive_complexity = "1"]
 fn closures() {
     let x = |a: i32, b: i32| -> i32 {
+        //~^ ERROR: the function has a cognitive complexity of (2/1)
         if true {
             println!("moo");
         }
@@ -388,6 +405,7 @@ struct Moo;
 #[clippy::cognitive_complexity = "1"]
 impl Moo {
     fn moo(&self) {
+        //~^ ERROR: the function has a cognitive complexity of (2/1)
         if true {
             println!("moo");
         }
@@ -397,6 +415,7 @@ impl Moo {
 #[clippy::cognitive_complexity = "1"]
 mod issue9300 {
     async fn a() {
+        //~^ ERROR: the function has a cognitive complexity of (2/1)
         let a = 0;
         if a == 0 {}
     }
@@ -404,6 +423,7 @@ mod issue9300 {
     pub struct S;
     impl S {
         pub async fn async_method() {
+            //~^ ERROR: the function has a cognitive complexity of (2/1)
             let a = 0;
             if a == 0 {}
         }