{"action":"created","comment":{"url":"https://api.github.com/repos/square/metrics/pulls/comments/40002721","id":40002721,"diff_hunk":"@@ -66,22 +62,21 @@ func ReadMetricsFile(file string) ([]string, error) {\n \t\treturn nil, err\n \t}\n \n-\tresult := make(map[string]int)\n+\t// Read the data with a zlib reader\n \tr, err := zlib.NewReader(bytes.NewBuffer(data))\n+\tdefer r.Close()\n \tif err != nil {\n-\t\tpanic(\"Problem with zlib compressed data\")\n+\t\treturn nil, fmt.Errorf(\"Problem with zlib compressed data: %s\", err.Error())\n \t}\n-\tb := new(bytes.Buffer)\n-\tio.Copy(b, r)\n-\tr.Close()\n-\td := gob.NewDecoder(b)\n \n-\terr = d.Decode(&result)\n+\t// Store the result of the decode in this map:\n+\tresult := map[string]int{}\n+\terr = gob.NewDecoder(r).Decode(&result)\n \tif err != nil {\n \t\treturn nil, err\n \t}\n \n-\tstrings := []string{}\n+\tstrings := make([]string, 0, len(result))","path":"main/ruletester/ruletester.go","position":53,"original_position":53,"commit_id":"4b6ca8cc373ae84243cbd23b05962132518f151e","original_commit_id":"4b6ca8cc373ae84243cbd23b05962132518f151e","user":{"login":"cchandler","id":26321,"avatar_url":"https://avatars.githubusercontent.com/u/26321?v=3","gravatar_id":"","url":"https://api.github.com/users/cchandler","html_url":"https://github.com/cchandler","followers_url":"https://api.github.com/users/cchandler/followers","following_url":"https://api.github.com/users/cchandler/following{/other_user}","gists_url":"https://api.github.com/users/cchandler/gists{/gist_id}","starred_url":"https://api.github.com/users/cchandler/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cchandler/subscriptions","organizations_url":"https://api.github.com/users/cchandler/orgs","repos_url":"https://api.github.com/users/cchandler/repos","events_url":"https://api.github.com/users/cchandler/events{/privacy}","received_events_url":"https://api.github.com/users/cchandler/received_events","type":"User","site_admin":false},"body":"Let's come up with consistent style. This one keeps coming up. For an empty slice I'm leaning toward `[]string{}`. @achow ?","created_at":"2015-09-21T17:55:10Z","updated_at":"2015-09-21T17:55:10Z","html_url":"https://github.com/square/metrics/pull/210#discussion_r40002721","pull_request_url":"https://api.github.com/repos/square/metrics/pulls/210","_links":{"self":{"href":"https://api.github.com/repos/square/metrics/pulls/comments/40002721"},"html":{"href":"https://github.com/square/metrics/pull/210#discussion_r40002721"},"pull_request":{"href":"https://api.github.com/repos/square/metrics/pulls/210"}}},"pull_request":{"url":"https://api.github.com/repos/square/metrics/pulls/210","id":45506873,"html_url":"https://github.com/square/metrics/pull/210","diff_url":"https://github.com/square/metrics/pull/210.diff","patch_url":"https://github.com/square/metrics/pull/210.patch","issue_url":"https://api.github.com/repos/square/metrics/issues/210","number":210,"state":"open","locked":false,"title":"Ruletester Cleanup / Usability Improvements","user":{"login":"Nathan-Fenner","id":6179181,"avatar_url":"https://avatars.githubusercontent.com/u/6179181?v=3","gravatar_id":"","url":"https://api.github.com/users/Nathan-Fenner","html_url":"https://github.com/Nathan-Fenner","followers_url":"https://api.github.com/users/Nathan-Fenner/followers","following_url":"https://api.github.com/users/Nathan-Fenner/following{/other_user}","gists_url":"https://api.github.com/users/Nathan-Fenner/gists{/gist_id}","starred_url":"https://api.github.com/users/Nathan-Fenner/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Nathan-Fenner/subscriptions","organizations_url":"https://api.github.com/users/Nathan-Fenner/orgs","repos_url":"https://api.github.com/users/Nathan-Fenner/repos","events_url":"https://api.github.com/users/Nathan-Fenner/events{/privacy}","received_events_url":"https://api.github.com/users/Nathan-Fenner/received_events","type":"User","site_admin":false},"body":"While trying out the new ruletester, I ran into a few problems that were pretty straightforward to solve:\r\n\r\n* When a flag is missing, say what flag it is: namely `-metrics-file` and `-rule-path`\r\n* Don't ask for a complete configuration file (doesn't need `-config-file`)- only the conversion rule path was being used, so the rest of the config was extraneous\r\n* Increase `runtime.GOMAXPROCS` to `runtime.NumCPU()` so that it runs fully in parallel - this increased speed slightly on my machine\r\n\r\nI also just cleaned up the commented code and some unused functions, and added error checking in a handful of places.\r\n\r\nThe batching of metrics obscured what was going on in the code a little bit- so I got rid of it. Running the program a few times on my machine took ~65s (real/clock time) either way.\r\n\r\nTo help find buggy conversion rules, metrics which fail to be reversed are printed after the ruletester runs. Additionally, rules are now checked for successful conversion back into the original graphite, and these are also printed if they differ from the expected original.","created_at":"2015-09-20T23:39:34Z","updated_at":"2015-09-21T17:55:10Z","closed_at":null,"merged_at":null,"merge_commit_sha":"ea464bc4f062d0b2ddf6793f65847c29673ac2be","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/square/metrics/pulls/210/commits","review_comments_url":"https://api.github.com/repos/square/metrics/pulls/210/comments","review_comment_url":"https://api.github.com/repos/square/metrics/pulls/comments{/number}","comments_url":"https://api.github.com/repos/square/metrics/issues/210/comments","statuses_url":"https://api.github.com/repos/square/metrics/statuses/4b6ca8cc373ae84243cbd23b05962132518f151e","head":{"label":"square:nathanfenner-ruletester-cleanup","ref":"nathanfenner-ruletester-cleanup","sha":"4b6ca8cc373ae84243cbd23b05962132518f151e","user":{"login":"square","id":82592,"avatar_url":"https://avatars.githubusercontent.com/u/82592?v=3","gravatar_id":"","url":"https://api.github.com/users/square","html_url":"https://github.com/square","followers_url":"https://api.github.com/users/square/followers","following_url":"https://api.github.com/users/square/following{/other_user}","gists_url":"https://api.github.com/users/square/gists{/gist_id}","starred_url":"https://api.github.com/users/square/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/square/subscriptions","organizations_url":"https://api.github.com/users/square/orgs","repos_url":"https://api.github.com/users/square/repos","events_url":"https://api.github.com/users/square/events{/privacy}","received_events_url":"https://api.github.com/users/square/received_events","type":"Organization","site_admin":false},"repo":{"id":34279409,"name":"metrics","full_name":"square/metrics","owner":{"login":"square","id":82592,"avatar_url":"https://avatars.githubusercontent.com/u/82592?v=3","gravatar_id":"","url":"https://api.github.com/users/square","html_url":"https://github.com/square","followers_url":"https://api.github.com/users/square/followers","following_url":"https://api.github.com/users/square/following{/other_user}","gists_url":"https://api.github.com/users/square/gists{/gist_id}","starred_url":"https://api.github.com/users/square/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/square/subscriptions","organizations_url":"https://api.github.com/users/square/orgs","repos_url":"https://api.github.com/users/square/repos","events_url":"https://api.github.com/users/square/events{/privacy}","received_events_url":"https://api.github.com/users/square/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/square/metrics","description":"Metrics Query Engine","fork":false,"url":"https://api.github.com/repos/square/metrics","forks_url":"https://api.github.com/repos/square/metrics/forks","keys_url":"https://api.github.com/repos/square/metrics/keys{/key_id}","collaborators_url":"https://api.github.com/repos/square/metrics/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/square/metrics/teams","hooks_url":"https://api.github.com/repos/square/metrics/hooks","issue_events_url":"https://api.github.com/repos/square/metrics/issues/events{/number}","events_url":"https://api.github.com/repos/square/metrics/events","assignees_url":"https://api.github.com/repos/square/metrics/assignees{/user}","branches_url":"https://api.github.com/repos/square/metrics/branches{/branch}","tags_url":"https://api.github.com/repos/square/metrics/tags","blobs_url":"https://api.github.com/repos/square/metrics/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/square/metrics/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/square/metrics/git/refs{/sha}","trees_url":"https://api.github.com/repos/square/metrics/git/trees{/sha}","statuses_url":"https://api.github.com/repos/square/metrics/statuses/{sha}","languages_url":"https://api.github.com/repos/square/metrics/languages","stargazers_url":"https://api.github.com/repos/square/metrics/stargazers","contributors_url":"https://api.github.com/repos/square/metrics/contributors","subscribers_url":"https://api.github.com/repos/square/metrics/subscribers","subscription_url":"https://api.github.com/repos/square/metrics/subscription","commits_url":"https://api.github.com/repos/square/metrics/commits{/sha}","git_commits_url":"https://api.github.com/repos/square/metrics/git/commits{/sha}","comments_url":"https://api.github.com/repos/square/metrics/comments{/number}","issue_comment_url":"https://api.github.com/repos/square/metrics/issues/comments{/number}","contents_url":"https://api.github.com/repos/square/metrics/contents/{+path}","compare_url":"https://api.github.com/repos/square/metrics/compare/{base}...{head}","merges_url":"https://api.github.com/repos/square/metrics/merges","archive_url":"https://api.github.com/repos/square/metrics/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/square/metrics/downloads","issues_url":"https://api.github.com/repos/square/metrics/issues{/number}","pulls_url":"https://api.github.com/repos/square/metrics/pulls{/number}","milestones_url":"https://api.github.com/repos/square/metrics/milestones{/number}","notifications_url":"https://api.github.com/repos/square/metrics/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/square/metrics/labels{/name}","releases_url":"https://api.github.com/repos/square/metrics/releases{/id}","created_at":"2015-04-20T18:43:35Z","updated_at":"2015-09-14T10:47:48Z","pushed_at":"2015-09-20T23:39:35Z","git_url":"git://github.com/square/metrics.git","ssh_url":"git@github.com:square/metrics.git","clone_url":"https://github.com/square/metrics.git","svn_url":"https://github.com/square/metrics","homepage":"","size":3864,"stargazers_count":23,"watchers_count":23,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":6,"mirror_url":null,"open_issues_count":4,"forks":6,"open_issues":4,"watchers":23,"default_branch":"master"}},"base":{"label":"square:master","ref":"master","sha":"da8bc2ab919a2831338aefb6b0c7ee32b090dade","user":{"login":"square","id":82592,"avatar_url":"https://avatars.githubusercontent.com/u/82592?v=3","gravatar_id":"","url":"https://api.github.com/users/square","html_url":"https://github.com/square","followers_url":"https://api.github.com/users/square/followers","following_url":"https://api.github.com/users/square/following{/other_user}","gists_url":"https://api.github.com/users/square/gists{/gist_id}","starred_url":"https://api.github.com/users/square/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/square/subscriptions","organizations_url":"https://api.github.com/users/square/orgs","repos_url":"https://api.github.com/users/square/repos","events_url":"https://api.github.com/users/square/events{/privacy}","received_events_url":"https://api.github.com/users/square/received_events","type":"Organization","site_admin":false},"repo":{"id":34279409,"name":"metrics","full_name":"square/metrics","owner":{"login":"square","id":82592,"avatar_url":"https://avatars.githubusercontent.com/u/82592?v=3","gravatar_id":"","url":"https://api.github.com/users/square","html_url":"https://github.com/square","followers_url":"https://api.github.com/users/square/followers","following_url":"https://api.github.com/users/square/following{/other_user}","gists_url":"https://api.github.com/users/square/gists{/gist_id}","starred_url":"https://api.github.com/users/square/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/square/subscriptions","organizations_url":"https://api.github.com/users/square/orgs","repos_url":"https://api.github.com/users/square/repos","events_url":"https://api.github.com/users/square/events{/privacy}","received_events_url":"https://api.github.com/users/square/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/square/metrics","description":"Metrics Query Engine","fork":false,"url":"https://api.github.com/repos/square/metrics","forks_url":"https://api.github.com/repos/square/metrics/forks","keys_url":"https://api.github.com/repos/square/metrics/keys{/key_id}","collaborators_url":"https://api.github.com/repos/square/metrics/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/square/metrics/teams","hooks_url":"https://api.github.com/repos/square/metrics/hooks","issue_events_url":"https://api.github.com/repos/square/metrics/issues/events{/number}","events_url":"https://api.github.com/repos/square/metrics/events","assignees_url":"https://api.github.com/repos/square/metrics/assignees{/user}","branches_url":"https://api.github.com/repos/square/metrics/branches{/branch}","tags_url":"https://api.github.com/repos/square/metrics/tags","blobs_url":"https://api.github.com/repos/square/metrics/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/square/metrics/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/square/metrics/git/refs{/sha}","trees_url":"https://api.github.com/repos/square/metrics/git/trees{/sha}","statuses_url":"https://api.github.com/repos/square/metrics/statuses/{sha}","languages_url":"https://api.github.com/repos/square/metrics/languages","stargazers_url":"https://api.github.com/repos/square/metrics/stargazers","contributors_url":"https://api.github.com/repos/square/metrics/contributors","subscribers_url":"https://api.github.com/repos/square/metrics/subscribers","subscription_url":"https://api.github.com/repos/square/metrics/subscription","commits_url":"https://api.github.com/repos/square/metrics/commits{/sha}","git_commits_url":"https://api.github.com/repos/square/metrics/git/commits{/sha}","comments_url":"https://api.github.com/repos/square/metrics/comments{/number}","issue_comment_url":"https://api.github.com/repos/square/metrics/issues/comments{/number}","contents_url":"https://api.github.com/repos/square/metrics/contents/{+path}","compare_url":"https://api.github.com/repos/square/metrics/compare/{base}...{head}","merges_url":"https://api.github.com/repos/square/metrics/merges","archive_url":"https://api.github.com/repos/square/metrics/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/square/metrics/downloads","issues_url":"https://api.github.com/repos/square/metrics/issues{/number}","pulls_url":"https://api.github.com/repos/square/metrics/pulls{/number}","milestones_url":"https://api.github.com/repos/square/metrics/milestones{/number}","notifications_url":"https://api.github.com/repos/square/metrics/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/square/metrics/labels{/name}","releases_url":"https://api.github.com/repos/square/metrics/releases{/id}","created_at":"2015-04-20T18:43:35Z","updated_at":"2015-09-14T10:47:48Z","pushed_at":"2015-09-20T23:39:35Z","git_url":"git://github.com/square/metrics.git","ssh_url":"git@github.com:square/metrics.git","clone_url":"https://github.com/square/metrics.git","svn_url":"https://github.com/square/metrics","homepage":"","size":3864,"stargazers_count":23,"watchers_count":23,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":6,"mirror_url":null,"open_issues_count":4,"forks":6,"open_issues":4,"watchers":23,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/square/metrics/pulls/210"},"html":{"href":"https://github.com/square/metrics/pull/210"},"issue":{"href":"https://api.github.com/repos/square/metrics/issues/210"},"comments":{"href":"https://api.github.com/repos/square/metrics/issues/210/comments"},"review_comments":{"href":"https://api.github.com/repos/square/metrics/pulls/210/comments"},"review_comment":{"href":"https://api.github.com/repos/square/metrics/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/square/metrics/pulls/210/commits"},"statuses":{"href":"https://api.github.com/repos/square/metrics/statuses/4b6ca8cc373ae84243cbd23b05962132518f151e"}}}}