2 #![warn(clippy::cognitive_complexity)]
3 #![allow(unused, unused_crate_dependencies)]
90 #[clippy::cognitive_complexity = "1"]
115 1 => println!("hai"),
116 2 => println!("hey"),
117 3 => println!("hallo"),
118 4 => println!("hello"),
119 5 => println!("salut"),
120 6 => println!("good morning"),
121 7 => println!("good evening"),
122 8 => println!("good afternoon"),
123 9 => println!("good night"),
124 10 => println!("bonjour"),
125 11 => println!("hej"),
126 12 => println!("hej hej"),
127 13 => println!("greetings earthling"),
128 14 => println!("take us to you leader"),
129 15 | 17 | 19 | 21 | 23 | 25 | 27 | 29 | 31 | 33 => println!("take us to you leader"),
130 35 | 37 | 39 | 41 | 43 | 45 | 47 | 49 | 51 | 53 => println!("there is no undefined behavior"),
131 55 | 57 | 59 | 61 | 63 | 65 | 67 | 69 | 71 | 73 => println!("I know borrow-fu"),
132 _ => println!("bye"),
136 // Short circuiting operations don't increase the complexity of a function.
137 // Note that the minimum complexity of a function is 1.
138 #[clippy::cognitive_complexity = "1"]
139 fn lots_of_short_circuits() -> bool {
140 true && false && true && false && true && false && true
143 #[clippy::cognitive_complexity = "1"]
144 fn lots_of_short_circuits2() -> bool {
145 true || false || true || false || true || false || true
148 #[clippy::cognitive_complexity = "1"]
150 let x = || match 99 {
166 #[clippy::cognitive_complexity = "1"]
170 _ => println!("bye"),
175 #[clippy::cognitive_complexity = "1"]
176 /// Tests are usually complex but simple at the same time. `clippy::cognitive_complexity` used to
177 /// give lots of false-positives in tests.
178 fn dont_warn_on_tests() {
181 _ => println!("bye"),
185 #[clippy::cognitive_complexity = "1"]
189 1 => println!("bla"),
190 2 | 3 => println!("blub"),
191 _ => println!("bye"),
195 #[clippy::cognitive_complexity = "1"]
199 1 => println!("bla"),
200 2 | 3 => println!("blub"),
201 _ => println!("bye"),
205 1 => println!("bla"),
206 2 | 3 => println!("blub"),
207 _ => println!("bye"),
211 #[clippy::cognitive_complexity = "1"]
216 2 | 3 => println!("blub"),
217 _ => println!("bye"),
221 #[clippy::cognitive_complexity = "1"]
226 2 | 3 => println!("blub"),
227 _ => println!("bye"),
232 2 | 3 => println!("blub"),
233 _ => println!("bye"),
237 #[clippy::cognitive_complexity = "1"]
241 1 => println!("bla"),
242 2 | 3 => panic!("blub"),
243 _ => println!("bye"),
247 #[clippy::cognitive_complexity = "1"]
251 1 => println!("bla"),
252 2 | 3 => panic!("blub"),
253 _ => println!("bye"),
257 1 => println!("bla"),
258 2 | 3 => panic!("blub"),
259 _ => println!("bye"),
263 #[clippy::cognitive_complexity = "1"]
273 #[clippy::cognitive_complexity = "1"]
274 pub fn read_file(input_path: &str) -> String {
276 use std::io::{Read, Write};
278 let mut file = match File::open(&Path::new(input_path)) {
281 panic!("Can't open {}: {}", input_path, err);
285 let mut bytes = Vec::new();
287 match file.read_to_end(&mut bytes) {
290 panic!("Can't read {}", input_path);
294 match String::from_utf8(bytes) {
295 Ok(contents) => contents,
297 panic!("{} is not UTF-8 encoded", input_path);
304 #[clippy::cognitive_complexity = "1"]
305 fn void(void: Void) {
311 #[clippy::cognitive_complexity = "1"]
312 fn mcarton_sees_all() {
317 #[clippy::cognitive_complexity = "1"]
318 fn try_() -> Result<i32, &'static str> {
321 _ => return Err("bla"),
325 #[clippy::cognitive_complexity = "1"]
326 fn try_again() -> Result<i32, &'static str> {
337 _ => return Err("bla"),
341 #[clippy::cognitive_complexity = "1"]
342 fn early() -> Result<i32, &'static str> {
355 #[clippy::cognitive_complexity = "1"]
356 fn early_ret() -> i32 {
357 let a = if true { 42 } else { return 0; };
358 let a = if a < 99 { 42 } else { return 0; };
359 let a = if a < 99 { 42 } else { return 0; };
360 let a = if a < 99 { 42 } else { return 0; };
361 let a = if a < 99 { 42 } else { return 0; };
362 let a = if a < 99 { 42 } else { return 0; };
363 let a = if a < 99 { 42 } else { return 0; };
364 let a = if a < 99 { 42 } else { return 0; };
365 let a = if a < 99 { 42 } else { return 0; };
366 let a = if a < 99 { 42 } else { return 0; };
367 let a = if a < 99 { 42 } else { return 0; };
368 let a = if a < 99 { 42 } else { return 0; };
375 #[clippy::cognitive_complexity = "1"]
377 let x = |a: i32, b: i32| -> i32 {
388 #[clippy::cognitive_complexity = "1"]