{"action":"closed","issue":{"url":"https://api.github.com/repos/opennota/check/issues/6","labels_url":"https://api.github.com/repos/opennota/check/issues/6/labels{/name}","comments_url":"https://api.github.com/repos/opennota/check/issues/6/comments","events_url":"https://api.github.com/repos/opennota/check/issues/6/events","html_url":"https://github.com/opennota/check/issues/6","id":41959114,"number":6,"title":"defercheck false positives","user":{"login":"robfig","id":536325,"avatar_url":"https://avatars.githubusercontent.com/u/536325?v=3","gravatar_id":"","url":"https://api.github.com/users/robfig","html_url":"https://github.com/robfig","followers_url":"https://api.github.com/users/robfig/followers","following_url":"https://api.github.com/users/robfig/following{/other_user}","gists_url":"https://api.github.com/users/robfig/gists{/gist_id}","starred_url":"https://api.github.com/users/robfig/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/robfig/subscriptions","organizations_url":"https://api.github.com/users/robfig/orgs","repos_url":"https://api.github.com/users/robfig/repos","events_url":"https://api.github.com/users/robfig/events{/privacy}","received_events_url":"https://api.github.com/users/robfig/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/opennota/check/labels/bug","name":"bug","color":"fc2929"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2014-09-04T16:49:09Z","updated_at":"2015-11-18T16:13:44Z","closed_at":"2015-11-18T16:13:44Z","body":"Great idea for the tools!\r\n\r\nI ran defercheck on my codebase and found 2 false positives, which I thought you may be interested to know, in case the check could be tightened.  Feel free to close this issue if it's not possible to recognize these cases\r\n\r\nCase 1 - Inline goroutines call WaitGroup.Done()\r\n```go\r\n\r\nif doStep {\r\n  wg.Add(1)\r\n  go func() { defer wg.Done(); ... }()\r\n}\r\nif doOtherStep {\r\n  wg.Add(1)\r\n  go func() { defer wg.Done(); ... }()\r\n}\r\n```\r\n\r\nCase 2 - Reassignment so that the defer calls are not on the same receiver\r\n```go\r\n        fileReader, _ := bucket.GetReader(file)\r\n        defer fileReader.Close()\r\n        if strings.HasSuffix(file, \".gz\") {\r\n                fileReader, _ = gzip.NewReader(fileReader)\r\n                defer fileReader.Close()\r\n        }\r\n\r\n       .. read file contents from fileReader ...\r\n```\r\n\r\nThanks again"}}