1 #![feature(tool_attributes)]
4 #![warn(cyclomatic_complexity)]
91 #[clippy::cyclomatic_complexity = "0"]
100 if j == 3 && k == 6 {
116 1 => println!("hai"),
117 2 => println!("hey"),
118 3 => println!("hallo"),
119 4 => println!("hello"),
120 5 => println!("salut"),
121 6 => println!("good morning"),
122 7 => println!("good evening"),
123 8 => println!("good afternoon"),
124 9 => println!("good night"),
125 10 => println!("bonjour"),
126 11 => println!("hej"),
127 12 => println!("hej hej"),
128 13 => println!("greetings earthling"),
129 14 => println!("take us to you leader"),
130 15 | 17 | 19 | 21 | 23 | 25 | 27 | 29 | 31 | 33 => println!("take us to you leader"),
131 35 | 37 | 39 | 41 | 43 | 45 | 47 | 49 | 51 | 53 => println!("there is no undefined behavior"),
132 55 | 57 | 59 | 61 | 63 | 65 | 67 | 69 | 71 | 73 => println!("I know borrow-fu"),
133 _ => println!("bye"),
137 #[clippy::cyclomatic_complexity = "0"]
138 fn lots_of_short_circuits() -> bool {
139 true && false && true && false && true && false && true
142 #[clippy::cyclomatic_complexity = "0"]
143 fn lots_of_short_circuits2() -> bool {
144 true || false || true || false || true || false || true
147 #[clippy::cyclomatic_complexity = "0"]
149 let x = || match 99 {
165 #[clippy::cyclomatic_complexity = "0"]
169 _ => println!("bye"),
174 #[clippy::cyclomatic_complexity = "0"]
175 /// Tests are usually complex but simple at the same time. `cyclomatic_complexity` used to give
176 /// lots of false-positives in tests.
177 fn dont_warn_on_tests() {
180 _ => println!("bye"),
184 #[clippy::cyclomatic_complexity = "0"]
188 1 => println!("bla"),
189 2 | 3 => println!("blub"),
190 _ => println!("bye"),
194 #[clippy::cyclomatic_complexity = "0"]
198 1 => println!("bla"),
199 2 | 3 => println!("blub"),
200 _ => println!("bye"),
204 1 => println!("bla"),
205 2 | 3 => println!("blub"),
206 _ => println!("bye"),
210 #[clippy::cyclomatic_complexity = "0"]
215 2 | 3 => println!("blub"),
216 _ => println!("bye"),
220 #[clippy::cyclomatic_complexity = "0"]
225 2 | 3 => println!("blub"),
226 _ => println!("bye"),
231 2 | 3 => println!("blub"),
232 _ => println!("bye"),
236 #[clippy::cyclomatic_complexity = "0"]
240 1 => println!("bla"),
241 2 | 3 => panic!("blub"),
242 _ => println!("bye"),
246 #[clippy::cyclomatic_complexity = "0"]
250 1 => println!("bla"),
251 2 | 3 => panic!("blub"),
252 _ => println!("bye"),
256 1 => println!("bla"),
257 2 | 3 => panic!("blub"),
258 _ => println!("bye"),
262 #[clippy::cyclomatic_complexity = "0"]
273 #[clippy::cyclomatic_complexity = "0"]
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::cyclomatic_complexity = "0"]
305 fn void(void: Void) {
312 #[clippy::cyclomatic_complexity = "0"]
313 fn mcarton_sees_all() {
318 #[clippy::cyclomatic_complexity = "0"]
319 fn try() -> Result<i32, &'static str> {
322 _ => return Err("bla"),
326 #[clippy::cyclomatic_complexity = "0"]
327 fn try_again() -> Result<i32, &'static str> {
328 let _ = try!(Ok(42));
329 let _ = try!(Ok(43));
330 let _ = try!(Ok(44));
331 let _ = try!(Ok(45));
332 let _ = try!(Ok(46));
333 let _ = try!(Ok(47));
334 let _ = try!(Ok(48));
335 let _ = try!(Ok(49));
338 _ => return Err("bla"),
342 #[clippy::cyclomatic_complexity = "0"]
343 fn early() -> Result<i32, &'static str> {
355 #[clippy::cyclomatic_complexity = "0"]
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; };