{"action":"created","issue":{"url":"https://api.github.com/repos/mebigfatguy/fb-contrib/issues/37","labels_url":"https://api.github.com/repos/mebigfatguy/fb-contrib/issues/37/labels{/name}","comments_url":"https://api.github.com/repos/mebigfatguy/fb-contrib/issues/37/comments","events_url":"https://api.github.com/repos/mebigfatguy/fb-contrib/issues/37/events","html_url":"https://github.com/mebigfatguy/fb-contrib/issues/37","id":64086350,"number":37,"title":"Proposal: Unnecessary Collection Nesting Detector","user":{"login":"tpounds","id":195041,"avatar_url":"https://avatars.githubusercontent.com/u/195041?v=3","gravatar_id":"","url":"https://api.github.com/users/tpounds","html_url":"https://github.com/tpounds","followers_url":"https://api.github.com/users/tpounds/followers","following_url":"https://api.github.com/users/tpounds/following{/other_user}","gists_url":"https://api.github.com/users/tpounds/gists{/gist_id}","starred_url":"https://api.github.com/users/tpounds/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tpounds/subscriptions","organizations_url":"https://api.github.com/users/tpounds/orgs","repos_url":"https://api.github.com/users/tpounds/repos","events_url":"https://api.github.com/users/tpounds/events{/privacy}","received_events_url":"https://api.github.com/users/tpounds/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-03-24T20:00:08Z","updated_at":"2015-03-24T21:32:34Z","closed_at":null,"body":"I noticed the following anti-pattern in some service code the other day. Arrays.asList(...) already creates a copy of the original array so nesting it inside an additional ArrayList is unnecessary.\r\n\r\n```java\r\nfinal List<...> valueList = new ArrayList<...>(Arrays.<...>asList(valueArray));\r\n```\r\n\r\nI'll take a crack at adding new detector for this bug but wanted to report it in case anyone wanted to get to it beforehand."},"comment":{"url":"https://api.github.com/repos/mebigfatguy/fb-contrib/issues/comments/85702879","html_url":"https://github.com/mebigfatguy/fb-contrib/issues/37#issuecomment-85702879","issue_url":"https://api.github.com/repos/mebigfatguy/fb-contrib/issues/37","id":85702879,"user":{"login":"mebigfatguy","id":170161,"avatar_url":"https://avatars.githubusercontent.com/u/170161?v=3","gravatar_id":"","url":"https://api.github.com/users/mebigfatguy","html_url":"https://github.com/mebigfatguy","followers_url":"https://api.github.com/users/mebigfatguy/followers","following_url":"https://api.github.com/users/mebigfatguy/following{/other_user}","gists_url":"https://api.github.com/users/mebigfatguy/gists{/gist_id}","starred_url":"https://api.github.com/users/mebigfatguy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mebigfatguy/subscriptions","organizations_url":"https://api.github.com/users/mebigfatguy/orgs","repos_url":"https://api.github.com/users/mebigfatguy/repos","events_url":"https://api.github.com/users/mebigfatguy/events{/privacy}","received_events_url":"https://api.github.com/users/mebigfatguy/received_events","type":"User","site_admin":false},"created_at":"2015-03-24T21:32:34Z","updated_at":"2015-03-24T21:32:34Z","body":" \n\nI would suspect the reason they are doing this is because the List\nreturned from Arrays.asList is immutable, and they want to be able to\nadd or remove items or such. (unless you are saying you can determine\nthat the code will do no such thing, then that's another story. \n\n---\n<br type=\"_moz\" />\n\nOn 2015-03-24 16:00, Trevor Pounds wrote: \n\n> I noticed the following anti-pattern in some service code the other day. Arrays.asList(...) already creates a copy of the original array so nesting it inside an additional ArrayList is unnecessary. \n> \n> final List<...> valueList = new ArrayList<...>(Arrays.<...>asList(valueArray));\n> \n> I'll take a crack at adding new detector for this bug but wanted to report it in case anyone wanted to get to it beforehand. \n> \n> --\n> Reply to this email directly or view it on GitHub [1].\n \n\nLinks:\n------\n[1] https://github.com/mebigfatguy/fb-contrib/issues/37\n"}}