{"action":"created","comment":{"url":"https://api.github.com/repos/dominikh/go-staticcheck/pulls/comments/67565083","id":67565083,"diff_hunk":"@@ -0,0 +1,55 @@\n+package pkg\n+\n+import \"sync\"\n+\n+func fn1() {\n+\tvar x sync.Mutex\n+\tx.Lock()\n+\tx.Unlock() // MATCH /empty critical section/\n+}\n+\n+func fn2() {\n+\tx := struct {\n+\t\tm1 struct {\n+\t\t\tm2 sync.Mutex\n+\t\t}\n+\t}{}\n+\n+\tx.m1.m2.Lock()\n+\tx.m1.m2.Unlock() // MATCH /empty critical section/\n+\n+}\n+\n+func fn3() {\n+\tvar x sync.RWMutex\n+\tx.Lock()\n+\tx.Unlock() // MATCH /empty critical section/\n+\n+\tx.RLock()\n+\tx.RUnlock() // MATCH /empty critical section/\n+\n+\tx.Lock()\n+\tdefer x.Unlock()\n+}\n+\n+func fn4() {\n+\n+\tx := struct {\n+\t\tm func() *sync.Mutex\n+\t}{\n+\t\tm: func() *sync.Mutex {\n+\t\t\treturn new(sync.Mutex)\n+\t\t},\n+\t}\n+\n+\tx.m().Lock()\n+\tx.m().Unlock()","path":"testdata/empty-critical-section.go","position":46,"original_position":46,"commit_id":"41cd97743a5a1f5321f3de5f43e2def2ba5ee68d","original_commit_id":"41cd97743a5a1f5321f3de5f43e2def2ba5ee68d","user":{"login":"dominikh","id":39825,"avatar_url":"https://avatars.githubusercontent.com/u/39825?v=3","gravatar_id":"","url":"https://api.github.com/users/dominikh","html_url":"https://github.com/dominikh","followers_url":"https://api.github.com/users/dominikh/followers","following_url":"https://api.github.com/users/dominikh/following{/other_user}","gists_url":"https://api.github.com/users/dominikh/gists{/gist_id}","starred_url":"https://api.github.com/users/dominikh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dominikh/subscriptions","organizations_url":"https://api.github.com/users/dominikh/orgs","repos_url":"https://api.github.com/users/dominikh/repos","events_url":"https://api.github.com/users/dominikh/events{/privacy}","received_events_url":"https://api.github.com/users/dominikh/received_events","type":"User","site_admin":false},"body":"Never mind, I see why.","created_at":"2016-06-17T19:45:08Z","updated_at":"2016-06-17T19:45:08Z","html_url":"https://github.com/dominikh/go-staticcheck/pull/7#discussion_r67565083","pull_request_url":"https://api.github.com/repos/dominikh/go-staticcheck/pulls/7","_links":{"self":{"href":"https://api.github.com/repos/dominikh/go-staticcheck/pulls/comments/67565083"},"html":{"href":"https://github.com/dominikh/go-staticcheck/pull/7#discussion_r67565083"},"pull_request":{"href":"https://api.github.com/repos/dominikh/go-staticcheck/pulls/7"}}},"pull_request":{"url":"https://api.github.com/repos/dominikh/go-staticcheck/pulls/7","id":74285919,"html_url":"https://github.com/dominikh/go-staticcheck/pull/7","diff_url":"https://github.com/dominikh/go-staticcheck/pull/7.diff","patch_url":"https://github.com/dominikh/go-staticcheck/pull/7.patch","issue_url":"https://api.github.com/repos/dominikh/go-staticcheck/issues/7","number":7,"state":"open","locked":false,"title":"Implementing empty critical section check","user":{"login":"MohamedBassem","id":2418637,"avatar_url":"https://avatars.githubusercontent.com/u/2418637?v=3","gravatar_id":"","url":"https://api.github.com/users/MohamedBassem","html_url":"https://github.com/MohamedBassem","followers_url":"https://api.github.com/users/MohamedBassem/followers","following_url":"https://api.github.com/users/MohamedBassem/following{/other_user}","gists_url":"https://api.github.com/users/MohamedBassem/gists{/gist_id}","starred_url":"https://api.github.com/users/MohamedBassem/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MohamedBassem/subscriptions","organizations_url":"https://api.github.com/users/MohamedBassem/orgs","repos_url":"https://api.github.com/users/MohamedBassem/repos","events_url":"https://api.github.com/users/MohamedBassem/events{/privacy}","received_events_url":"https://api.github.com/users/MohamedBassem/received_events","type":"User","site_admin":false},"body":"@dgryski asked for an empty critical section check. To detect missing defers.\r\n\r\nQuoting @dgryski : \r\ndominikh: idea for a static check (from code pushed to our internal repo):\r\n```go\r\nfunc Close() error {\r\n       containersMutex.Lock()\r\n       containersMutex.Unlock()   //  <-- empty critical section, missing defer\r\n       for _, c := range containers {\r\n               c.Close()\r\n       }\r\n\r\n       return nil\r\n}\r\n```\r\nIt's my first pull request to an open source Go project. So please let me know if there's anything that needs to be modified.","created_at":"2016-06-17T18:31:14Z","updated_at":"2016-06-17T19:45:08Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b2f1456583bafc7b6af00d90e43e9d2e746d86cf","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/dominikh/go-staticcheck/pulls/7/commits","review_comments_url":"https://api.github.com/repos/dominikh/go-staticcheck/pulls/7/comments","review_comment_url":"https://api.github.com/repos/dominikh/go-staticcheck/pulls/comments{/number}","comments_url":"https://api.github.com/repos/dominikh/go-staticcheck/issues/7/comments","statuses_url":"https://api.github.com/repos/dominikh/go-staticcheck/statuses/41cd97743a5a1f5321f3de5f43e2def2ba5ee68d","head":{"label":"MohamedBassem:empty-critical-section","ref":"empty-critical-section","sha":"41cd97743a5a1f5321f3de5f43e2def2ba5ee68d","user":{"login":"MohamedBassem","id":2418637,"avatar_url":"https://avatars.githubusercontent.com/u/2418637?v=3","gravatar_id":"","url":"https://api.github.com/users/MohamedBassem","html_url":"https://github.com/MohamedBassem","followers_url":"https://api.github.com/users/MohamedBassem/followers","following_url":"https://api.github.com/users/MohamedBassem/following{/other_user}","gists_url":"https://api.github.com/users/MohamedBassem/gists{/gist_id}","starred_url":"https://api.github.com/users/MohamedBassem/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MohamedBassem/subscriptions","organizations_url":"https://api.github.com/users/MohamedBassem/orgs","repos_url":"https://api.github.com/users/MohamedBassem/repos","events_url":"https://api.github.com/users/MohamedBassem/events{/privacy}","received_events_url":"https://api.github.com/users/MohamedBassem/received_events","type":"User","site_admin":false},"repo":{"id":61382160,"name":"go-staticcheck","full_name":"MohamedBassem/go-staticcheck","owner":{"login":"MohamedBassem","id":2418637,"avatar_url":"https://avatars.githubusercontent.com/u/2418637?v=3","gravatar_id":"","url":"https://api.github.com/users/MohamedBassem","html_url":"https://github.com/MohamedBassem","followers_url":"https://api.github.com/users/MohamedBassem/followers","following_url":"https://api.github.com/users/MohamedBassem/following{/other_user}","gists_url":"https://api.github.com/users/MohamedBassem/gists{/gist_id}","starred_url":"https://api.github.com/users/MohamedBassem/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MohamedBassem/subscriptions","organizations_url":"https://api.github.com/users/MohamedBassem/orgs","repos_url":"https://api.github.com/users/MohamedBassem/repos","events_url":"https://api.github.com/users/MohamedBassem/events{/privacy}","received_events_url":"https://api.github.com/users/MohamedBassem/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/MohamedBassem/go-staticcheck","description":"Staticcheck is a tool for statically checking the inputs to certain functions, such as regexp.Compile","fork":true,"url":"https://api.github.com/repos/MohamedBassem/go-staticcheck","forks_url":"https://api.github.com/repos/MohamedBassem/go-staticcheck/forks","keys_url":"https://api.github.com/repos/MohamedBassem/go-staticcheck/keys{/key_id}","collaborators_url":"https://api.github.com/repos/MohamedBassem/go-staticcheck/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/MohamedBassem/go-staticcheck/teams","hooks_url":"https://api.github.com/repos/MohamedBassem/go-staticcheck/hooks","issue_events_url":"https://api.github.com/repos/MohamedBassem/go-staticcheck/issues/events{/number}","events_url":"https://api.github.com/repos/MohamedBassem/go-staticcheck/events","assignees_url":"https://api.github.com/repos/MohamedBassem/go-staticcheck/assignees{/user}","branches_url":"https://api.github.com/repos/MohamedBassem/go-staticcheck/branches{/branch}","tags_url":"https://api.github.com/repos/MohamedBassem/go-staticcheck/tags","blobs_url":"https://api.github.com/repos/MohamedBassem/go-staticcheck/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/MohamedBassem/go-staticcheck/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/MohamedBassem/go-staticcheck/git/refs{/sha}","trees_url":"https://api.github.com/repos/MohamedBassem/go-staticcheck/git/trees{/sha}","statuses_url":"https://api.github.com/repos/MohamedBassem/go-staticcheck/statuses/{sha}","languages_url":"https://api.github.com/repos/MohamedBassem/go-staticcheck/languages","stargazers_url":"https://api.github.com/repos/MohamedBassem/go-staticcheck/stargazers","contributors_url":"https://api.github.com/repos/MohamedBassem/go-staticcheck/contributors","subscribers_url":"https://api.github.com/repos/MohamedBassem/go-staticcheck/subscribers","subscription_url":"https://api.github.com/repos/MohamedBassem/go-staticcheck/subscription","commits_url":"https://api.github.com/repos/MohamedBassem/go-staticcheck/commits{/sha}","git_commits_url":"https://api.github.com/repos/MohamedBassem/go-staticcheck/git/commits{/sha}","comments_url":"https://api.github.com/repos/MohamedBassem/go-staticcheck/comments{/number}","issue_comment_url":"https://api.github.com/repos/MohamedBassem/go-staticcheck/issues/comments{/number}","contents_url":"https://api.github.com/repos/MohamedBassem/go-staticcheck/contents/{+path}","compare_url":"https://api.github.com/repos/MohamedBassem/go-staticcheck/compare/{base}...{head}","merges_url":"https://api.github.com/repos/MohamedBassem/go-staticcheck/merges","archive_url":"https://api.github.com/repos/MohamedBassem/go-staticcheck/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/MohamedBassem/go-staticcheck/downloads","issues_url":"https://api.github.com/repos/MohamedBassem/go-staticcheck/issues{/number}","pulls_url":"https://api.github.com/repos/MohamedBassem/go-staticcheck/pulls{/number}","milestones_url":"https://api.github.com/repos/MohamedBassem/go-staticcheck/milestones{/number}","notifications_url":"https://api.github.com/repos/MohamedBassem/go-staticcheck/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/MohamedBassem/go-staticcheck/labels{/name}","releases_url":"https://api.github.com/repos/MohamedBassem/go-staticcheck/releases{/id}","deployments_url":"https://api.github.com/repos/MohamedBassem/go-staticcheck/deployments","created_at":"2016-06-17T15:03:59Z","updated_at":"2016-06-17T15:04:05Z","pushed_at":"2016-06-17T18:20:18Z","git_url":"git://github.com/MohamedBassem/go-staticcheck.git","ssh_url":"git@github.com:MohamedBassem/go-staticcheck.git","clone_url":"https://github.com/MohamedBassem/go-staticcheck.git","svn_url":"https://github.com/MohamedBassem/go-staticcheck","homepage":"","size":42,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"dominikh:master","ref":"master","sha":"a9330d18e74f715869622ca8c58d4e231191b13c","user":{"login":"dominikh","id":39825,"avatar_url":"https://avatars.githubusercontent.com/u/39825?v=3","gravatar_id":"","url":"https://api.github.com/users/dominikh","html_url":"https://github.com/dominikh","followers_url":"https://api.github.com/users/dominikh/followers","following_url":"https://api.github.com/users/dominikh/following{/other_user}","gists_url":"https://api.github.com/users/dominikh/gists{/gist_id}","starred_url":"https://api.github.com/users/dominikh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dominikh/subscriptions","organizations_url":"https://api.github.com/users/dominikh/orgs","repos_url":"https://api.github.com/users/dominikh/repos","events_url":"https://api.github.com/users/dominikh/events{/privacy}","received_events_url":"https://api.github.com/users/dominikh/received_events","type":"User","site_admin":false},"repo":{"id":55308508,"name":"go-staticcheck","full_name":"dominikh/go-staticcheck","owner":{"login":"dominikh","id":39825,"avatar_url":"https://avatars.githubusercontent.com/u/39825?v=3","gravatar_id":"","url":"https://api.github.com/users/dominikh","html_url":"https://github.com/dominikh","followers_url":"https://api.github.com/users/dominikh/followers","following_url":"https://api.github.com/users/dominikh/following{/other_user}","gists_url":"https://api.github.com/users/dominikh/gists{/gist_id}","starred_url":"https://api.github.com/users/dominikh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dominikh/subscriptions","organizations_url":"https://api.github.com/users/dominikh/orgs","repos_url":"https://api.github.com/users/dominikh/repos","events_url":"https://api.github.com/users/dominikh/events{/privacy}","received_events_url":"https://api.github.com/users/dominikh/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/dominikh/go-staticcheck","description":"Staticcheck is a tool for statically checking the inputs to certain functions, such as regexp.Compile","fork":false,"url":"https://api.github.com/repos/dominikh/go-staticcheck","forks_url":"https://api.github.com/repos/dominikh/go-staticcheck/forks","keys_url":"https://api.github.com/repos/dominikh/go-staticcheck/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dominikh/go-staticcheck/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dominikh/go-staticcheck/teams","hooks_url":"https://api.github.com/repos/dominikh/go-staticcheck/hooks","issue_events_url":"https://api.github.com/repos/dominikh/go-staticcheck/issues/events{/number}","events_url":"https://api.github.com/repos/dominikh/go-staticcheck/events","assignees_url":"https://api.github.com/repos/dominikh/go-staticcheck/assignees{/user}","branches_url":"https://api.github.com/repos/dominikh/go-staticcheck/branches{/branch}","tags_url":"https://api.github.com/repos/dominikh/go-staticcheck/tags","blobs_url":"https://api.github.com/repos/dominikh/go-staticcheck/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dominikh/go-staticcheck/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dominikh/go-staticcheck/git/refs{/sha}","trees_url":"https://api.github.com/repos/dominikh/go-staticcheck/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dominikh/go-staticcheck/statuses/{sha}","languages_url":"https://api.github.com/repos/dominikh/go-staticcheck/languages","stargazers_url":"https://api.github.com/repos/dominikh/go-staticcheck/stargazers","contributors_url":"https://api.github.com/repos/dominikh/go-staticcheck/contributors","subscribers_url":"https://api.github.com/repos/dominikh/go-staticcheck/subscribers","subscription_url":"https://api.github.com/repos/dominikh/go-staticcheck/subscription","commits_url":"https://api.github.com/repos/dominikh/go-staticcheck/commits{/sha}","git_commits_url":"https://api.github.com/repos/dominikh/go-staticcheck/git/commits{/sha}","comments_url":"https://api.github.com/repos/dominikh/go-staticcheck/comments{/number}","issue_comment_url":"https://api.github.com/repos/dominikh/go-staticcheck/issues/comments{/number}","contents_url":"https://api.github.com/repos/dominikh/go-staticcheck/contents/{+path}","compare_url":"https://api.github.com/repos/dominikh/go-staticcheck/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dominikh/go-staticcheck/merges","archive_url":"https://api.github.com/repos/dominikh/go-staticcheck/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dominikh/go-staticcheck/downloads","issues_url":"https://api.github.com/repos/dominikh/go-staticcheck/issues{/number}","pulls_url":"https://api.github.com/repos/dominikh/go-staticcheck/pulls{/number}","milestones_url":"https://api.github.com/repos/dominikh/go-staticcheck/milestones{/number}","notifications_url":"https://api.github.com/repos/dominikh/go-staticcheck/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dominikh/go-staticcheck/labels{/name}","releases_url":"https://api.github.com/repos/dominikh/go-staticcheck/releases{/id}","deployments_url":"https://api.github.com/repos/dominikh/go-staticcheck/deployments","created_at":"2016-04-02T17:55:32Z","updated_at":"2016-06-09T11:51:10Z","pushed_at":"2016-06-17T18:31:14Z","git_url":"git://github.com/dominikh/go-staticcheck.git","ssh_url":"git@github.com:dominikh/go-staticcheck.git","clone_url":"https://github.com/dominikh/go-staticcheck.git","svn_url":"https://github.com/dominikh/go-staticcheck","homepage":"","size":41,"stargazers_count":117,"watchers_count":117,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":3,"forks":1,"open_issues":3,"watchers":117,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/dominikh/go-staticcheck/pulls/7"},"html":{"href":"https://github.com/dominikh/go-staticcheck/pull/7"},"issue":{"href":"https://api.github.com/repos/dominikh/go-staticcheck/issues/7"},"comments":{"href":"https://api.github.com/repos/dominikh/go-staticcheck/issues/7/comments"},"review_comments":{"href":"https://api.github.com/repos/dominikh/go-staticcheck/pulls/7/comments"},"review_comment":{"href":"https://api.github.com/repos/dominikh/go-staticcheck/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/dominikh/go-staticcheck/pulls/7/commits"},"statuses":{"href":"https://api.github.com/repos/dominikh/go-staticcheck/statuses/41cd97743a5a1f5321f3de5f43e2def2ba5ee68d"}}}}
{"actor":{"display_login":"dominikh"}}