{"action":"opened","issue":{"url":"https://api.github.com/repos/Manishearth/rust-clippy/issues/491","labels_url":"https://api.github.com/repos/Manishearth/rust-clippy/issues/491/labels{/name}","comments_url":"https://api.github.com/repos/Manishearth/rust-clippy/issues/491/comments","events_url":"https://api.github.com/repos/Manishearth/rust-clippy/issues/491/events","html_url":"https://github.com/Manishearth/rust-clippy/issues/491","id":121580987,"number":491,"title":"Bug calculating cyclomatic complexity","user":{"login":"msiemens","id":1873922,"avatar_url":"https://avatars.githubusercontent.com/u/1873922?v=3","gravatar_id":"","url":"https://api.github.com/users/msiemens","html_url":"https://github.com/msiemens","followers_url":"https://api.github.com/users/msiemens/followers","following_url":"https://api.github.com/users/msiemens/following{/other_user}","gists_url":"https://api.github.com/users/msiemens/gists{/gist_id}","starred_url":"https://api.github.com/users/msiemens/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/msiemens/subscriptions","organizations_url":"https://api.github.com/users/msiemens/orgs","repos_url":"https://api.github.com/users/msiemens/repos","events_url":"https://api.github.com/users/msiemens/events{/privacy}","received_events_url":"https://api.github.com/users/msiemens/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-12-10T21:26:48Z","updated_at":"2015-12-10T21:26:48Z","closed_at":null,"body":"Clippy asked me to file a bug report. It fails with this message:\r\n\r\n```plain\r\nsrc\\util\\io.rs:10:1: 36:2 note: Clippy encountered a bug calculating cyclomatic complexity (hide this message with `#[allow(cyclomatic_complexity)]`): cc = 1, arms = 2. Please file a bug report.\r\nsrc\\util\\io.rs:10 pub fn read_file(input_path: &str) -> String {\r\nsrc\\util\\io.rs:11     let mut file = match File::open(&Path::new(input_path)) {\r\nsrc\\util\\io.rs:12         Ok(f) => f,\r\nsrc\\util\\io.rs:13         Err(err) => {\r\nsrc\\util\\io.rs:14             fatal!(\"Can't open {}: {}\", input_path, err);\r\nsrc\\util\\io.rs:15             session().abort();\r\n                  ...\r\n```\r\n\r\nThe file mentioned in the snippet:\r\n\r\n```rust\r\n/// Read a file and return it's contents\r\n//! File I/O related helpers\r\n\r\nuse std::fs::File;\r\nuse std::io::{Read, Write};\r\nuse std::path::Path;\r\nuse driver::session;\r\n\r\n\r\n/// Read a file and return it's contents\r\npub fn read_file(input_path: &str) -> String {\r\n    let mut file = match File::open(&Path::new(input_path)) {\r\n        Ok(f) => f,\r\n        Err(err) => {\r\n            fatal!(\"Can't open {}: {}\", input_path, err);\r\n            session().abort();\r\n        }\r\n    };\r\n\r\n    let mut bytes = Vec::new();\r\n\r\n    match file.read_to_end(&mut bytes) {\r\n        Ok(..) => {},\r\n        Err(_) => {\r\n            fatal!(\"Can't read {}\", input_path);\r\n            session().abort();\r\n        }\r\n    };\r\n\r\n    match String::from_utf8(bytes) {\r\n        Ok(contents) => return contents,\r\n        Err(_) => {\r\n            fatal!(\"{} is not UTF-8 encoed\", input_path);\r\n            session().abort();\r\n        }\r\n    }\r\n}\r\n```\r\n\r\nVersions:\r\n\r\n```\r\nrustc 1.7.0-nightly (81ae8be71 2015-12-09)\r\ncargo 0.7.0-nightly (1af03be 2015-12-08)\r\n\r\n[[package]]\r\nname = \"clippy\"\r\nversion = \"0.0.30\"\r\nsource = \"git+https://github.com/Manishearth/rust-clippy#3e7677ff319a3b2989c29bc57d258e7b8f39fed6\"\r\n```"}}