2 #![warn(clippy::cognitive_complexity)]
90 #[clippy::cognitive_complexity = "0"]
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 #[clippy::cognitive_complexity = "0"]
137 fn lots_of_short_circuits() -> bool {
138 true && false && true && false && true && false && true
141 #[clippy::cognitive_complexity = "0"]
142 fn lots_of_short_circuits2() -> bool {
143 true || false || true || false || true || false || true
146 #[clippy::cognitive_complexity = "0"]
148 let x = || match 99 {
164 #[clippy::cognitive_complexity = "0"]
168 _ => println!("bye"),
173 #[clippy::cognitive_complexity = "0"]
174 /// Tests are usually complex but simple at the same time. `clippy::cognitive_complexity` used to
175 /// give lots of false-positives in tests.
176 fn dont_warn_on_tests() {
179 _ => println!("bye"),
183 #[clippy::cognitive_complexity = "0"]
187 1 => println!("bla"),
188 2 | 3 => println!("blub"),
189 _ => println!("bye"),
193 #[clippy::cognitive_complexity = "0"]
197 1 => println!("bla"),
198 2 | 3 => println!("blub"),
199 _ => println!("bye"),
203 1 => println!("bla"),
204 2 | 3 => println!("blub"),
205 _ => println!("bye"),
209 #[clippy::cognitive_complexity = "0"]
214 2 | 3 => println!("blub"),
215 _ => println!("bye"),
219 #[clippy::cognitive_complexity = "0"]
224 2 | 3 => println!("blub"),
225 _ => println!("bye"),
230 2 | 3 => println!("blub"),
231 _ => println!("bye"),
235 #[clippy::cognitive_complexity = "0"]
239 1 => println!("bla"),
240 2 | 3 => panic!("blub"),
241 _ => println!("bye"),
245 #[clippy::cognitive_complexity = "0"]
249 1 => println!("bla"),
250 2 | 3 => panic!("blub"),
251 _ => println!("bye"),
255 1 => println!("bla"),
256 2 | 3 => panic!("blub"),
257 _ => println!("bye"),
261 #[clippy::cognitive_complexity = "0"]
271 #[clippy::cognitive_complexity = "0"]
272 pub fn read_file(input_path: &str) -> String {
274 use std::io::{Read, Write};
276 let mut file = match File::open(&Path::new(input_path)) {
279 panic!("Can't open {}: {}", input_path, err);
283 let mut bytes = Vec::new();
285 match file.read_to_end(&mut bytes) {
288 panic!("Can't read {}", input_path);
292 match String::from_utf8(bytes) {
293 Ok(contents) => contents,
295 panic!("{} is not UTF-8 encoded", input_path);
302 #[clippy::cognitive_complexity = "0"]
303 fn void(void: Void) {
309 #[clippy::cognitive_complexity = "0"]
310 fn mcarton_sees_all() {
315 #[clippy::cognitive_complexity = "0"]
316 fn try_() -> Result<i32, &'static str> {
319 _ => return Err("bla"),
323 #[clippy::cognitive_complexity = "0"]
324 fn try_again() -> Result<i32, &'static str> {
325 let _ = r#try!(Ok(42));
326 let _ = r#try!(Ok(43));
327 let _ = r#try!(Ok(44));
328 let _ = r#try!(Ok(45));
329 let _ = r#try!(Ok(46));
330 let _ = r#try!(Ok(47));
331 let _ = r#try!(Ok(48));
332 let _ = r#try!(Ok(49));
335 _ => return Err("bla"),
339 #[clippy::cognitive_complexity = "0"]
340 fn early() -> Result<i32, &'static str> {
353 #[clippy::cognitive_complexity = "0"]
354 fn early_ret() -> i32 {
355 let a = if true { 42 } else { return 0; };
356 let a = if a < 99 { 42 } else { return 0; };
357 let a = if a < 99 { 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; };