{"action":"created","comment":{"url":"https://api.github.com/repos/avocado-framework/avocado/pulls/comments/23451087","id":23451087,"diff_hunk":"@@ -70,7 +70,12 @@ def passed(self):\n         return self.json['pass']\n \n     def pass_rate(self):\n-        pr = 100 * (float(self.json['pass']) / float(self.json['total']))\n+        total = self.json['total']\n+        passed = self.json['pass']\n+        if int(total) > 0:","path":"avocado/plugins/htmlresult.py","position":7,"original_position":7,"commit_id":"fc08e35d81080db55874cfed16c22f2bd093a61c","original_commit_id":"fc08e35d81080db55874cfed16c22f2bd093a61c","user":{"login":"clebergnu","id":447178,"avatar_url":"https://avatars.githubusercontent.com/u/447178?v=3","gravatar_id":"","url":"https://api.github.com/users/clebergnu","html_url":"https://github.com/clebergnu","followers_url":"https://api.github.com/users/clebergnu/followers","following_url":"https://api.github.com/users/clebergnu/following{/other_user}","gists_url":"https://api.github.com/users/clebergnu/gists{/gist_id}","starred_url":"https://api.github.com/users/clebergnu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/clebergnu/subscriptions","organizations_url":"https://api.github.com/users/clebergnu/orgs","repos_url":"https://api.github.com/users/clebergnu/repos","events_url":"https://api.github.com/users/clebergnu/events{/privacy}","received_events_url":"https://api.github.com/users/clebergnu/received_events","type":"User","site_admin":false},"body":"No doubt this code is sound, but enabling \"nitpick mode\" I'd write it as:\r\n\r\n```\r\n   total = float(self.json['total'])\r\n   passed = float(self.json['pass'])\r\n   if total > 0.0:\r\n      pr = 100 * (passed / total)\r\n   ...\r\n```\r\n\r\nResults in one less type conversion, and (nitpick++) a cleaner percentage calculation.\r\n\r\nQuestion to self: do we check somewhere if `total >= passed` ?","created_at":"2015-01-23T14:09:58Z","updated_at":"2015-01-23T14:09:58Z","html_url":"https://github.com/avocado-framework/avocado/pull/342#discussion_r23451087","pull_request_url":"https://api.github.com/repos/avocado-framework/avocado/pulls/342","_links":{"self":{"href":"https://api.github.com/repos/avocado-framework/avocado/pulls/comments/23451087"},"html":{"href":"https://github.com/avocado-framework/avocado/pull/342#discussion_r23451087"},"pull_request":{"href":"https://api.github.com/repos/avocado-framework/avocado/pulls/342"}}},"pull_request":{"url":"https://api.github.com/repos/avocado-framework/avocado/pulls/342","id":27862078,"html_url":"https://github.com/avocado-framework/avocado/pull/342","diff_url":"https://github.com/avocado-framework/avocado/pull/342.diff","patch_url":"https://github.com/avocado-framework/avocado/pull/342.patch","issue_url":"https://api.github.com/repos/avocado-framework/avocado/issues/342","number":342,"state":"open","locked":false,"title":"avocado.plugins.htmlresult: Fix bugs when interrupting the test","user":{"login":"lmr","id":296807,"avatar_url":"https://avatars.githubusercontent.com/u/296807?v=3","gravatar_id":"","url":"https://api.github.com/users/lmr","html_url":"https://github.com/lmr","followers_url":"https://api.github.com/users/lmr/followers","following_url":"https://api.github.com/users/lmr/following{/other_user}","gists_url":"https://api.github.com/users/lmr/gists{/gist_id}","starred_url":"https://api.github.com/users/lmr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lmr/subscriptions","organizations_url":"https://api.github.com/users/lmr/orgs","repos_url":"https://api.github.com/users/lmr/repos","events_url":"https://api.github.com/users/lmr/events{/privacy}","received_events_url":"https://api.github.com/users/lmr/received_events","type":"User","site_admin":false},"body":"If we stop a stand alone test execution in the middle, we'll\r\nhave troubles since there's still no available test ID to\r\nuse in the json. Let's fetch that information in advance\r\nfrom the file system.\r\n\r\nAlso, let's avoid a division by zero when no tests were\r\nfinished.\r\n\r\nSigned-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>","created_at":"2015-01-22T17:42:25Z","updated_at":"2015-01-23T14:09:58Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a8aff46561001cb4b22f1addd71d8f58f0f5e1e6","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/avocado-framework/avocado/pulls/342/commits","review_comments_url":"https://api.github.com/repos/avocado-framework/avocado/pulls/342/comments","review_comment_url":"https://api.github.com/repos/avocado-framework/avocado/pulls/comments/{number}","comments_url":"https://api.github.com/repos/avocado-framework/avocado/issues/342/comments","statuses_url":"https://api.github.com/repos/avocado-framework/avocado/statuses/fc08e35d81080db55874cfed16c22f2bd093a61c","head":{"label":"lmr:html_result_fix","ref":"html_result_fix","sha":"fc08e35d81080db55874cfed16c22f2bd093a61c","user":{"login":"lmr","id":296807,"avatar_url":"https://avatars.githubusercontent.com/u/296807?v=3","gravatar_id":"","url":"https://api.github.com/users/lmr","html_url":"https://github.com/lmr","followers_url":"https://api.github.com/users/lmr/followers","following_url":"https://api.github.com/users/lmr/following{/other_user}","gists_url":"https://api.github.com/users/lmr/gists{/gist_id}","starred_url":"https://api.github.com/users/lmr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lmr/subscriptions","organizations_url":"https://api.github.com/users/lmr/orgs","repos_url":"https://api.github.com/users/lmr/repos","events_url":"https://api.github.com/users/lmr/events{/privacy}","received_events_url":"https://api.github.com/users/lmr/received_events","type":"User","site_admin":false},"repo":{"id":24439240,"name":"avocado","full_name":"lmr/avocado","owner":{"login":"lmr","id":296807,"avatar_url":"https://avatars.githubusercontent.com/u/296807?v=3","gravatar_id":"","url":"https://api.github.com/users/lmr","html_url":"https://github.com/lmr","followers_url":"https://api.github.com/users/lmr/followers","following_url":"https://api.github.com/users/lmr/following{/other_user}","gists_url":"https://api.github.com/users/lmr/gists{/gist_id}","starred_url":"https://api.github.com/users/lmr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lmr/subscriptions","organizations_url":"https://api.github.com/users/lmr/orgs","repos_url":"https://api.github.com/users/lmr/repos","events_url":"https://api.github.com/users/lmr/events{/privacy}","received_events_url":"https://api.github.com/users/lmr/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/lmr/avocado","description":"Avocado Test Framework","fork":true,"url":"https://api.github.com/repos/lmr/avocado","forks_url":"https://api.github.com/repos/lmr/avocado/forks","keys_url":"https://api.github.com/repos/lmr/avocado/keys{/key_id}","collaborators_url":"https://api.github.com/repos/lmr/avocado/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/lmr/avocado/teams","hooks_url":"https://api.github.com/repos/lmr/avocado/hooks","issue_events_url":"https://api.github.com/repos/lmr/avocado/issues/events{/number}","events_url":"https://api.github.com/repos/lmr/avocado/events","assignees_url":"https://api.github.com/repos/lmr/avocado/assignees{/user}","branches_url":"https://api.github.com/repos/lmr/avocado/branches{/branch}","tags_url":"https://api.github.com/repos/lmr/avocado/tags","blobs_url":"https://api.github.com/repos/lmr/avocado/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/lmr/avocado/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/lmr/avocado/git/refs{/sha}","trees_url":"https://api.github.com/repos/lmr/avocado/git/trees{/sha}","statuses_url":"https://api.github.com/repos/lmr/avocado/statuses/{sha}","languages_url":"https://api.github.com/repos/lmr/avocado/languages","stargazers_url":"https://api.github.com/repos/lmr/avocado/stargazers","contributors_url":"https://api.github.com/repos/lmr/avocado/contributors","subscribers_url":"https://api.github.com/repos/lmr/avocado/subscribers","subscription_url":"https://api.github.com/repos/lmr/avocado/subscription","commits_url":"https://api.github.com/repos/lmr/avocado/commits{/sha}","git_commits_url":"https://api.github.com/repos/lmr/avocado/git/commits{/sha}","comments_url":"https://api.github.com/repos/lmr/avocado/comments{/number}","issue_comment_url":"https://api.github.com/repos/lmr/avocado/issues/comments/{number}","contents_url":"https://api.github.com/repos/lmr/avocado/contents/{+path}","compare_url":"https://api.github.com/repos/lmr/avocado/compare/{base}...{head}","merges_url":"https://api.github.com/repos/lmr/avocado/merges","archive_url":"https://api.github.com/repos/lmr/avocado/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/lmr/avocado/downloads","issues_url":"https://api.github.com/repos/lmr/avocado/issues{/number}","pulls_url":"https://api.github.com/repos/lmr/avocado/pulls{/number}","milestones_url":"https://api.github.com/repos/lmr/avocado/milestones{/number}","notifications_url":"https://api.github.com/repos/lmr/avocado/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/lmr/avocado/labels{/name}","releases_url":"https://api.github.com/repos/lmr/avocado/releases{/id}","created_at":"2014-09-25T01:39:41Z","updated_at":"2015-01-22T13:28:38Z","pushed_at":"2015-01-23T01:52:19Z","git_url":"git://github.com/lmr/avocado.git","ssh_url":"git@github.com:lmr/avocado.git","clone_url":"https://github.com/lmr/avocado.git","svn_url":"https://github.com/lmr/avocado","homepage":"http://avocado-framework.readthedocs.org/en/latest/","size":3173,"stargazers_count":0,"watchers_count":0,"language":"Python","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":"avocado-framework:master","ref":"master","sha":"92facc94adab6166875bab172ed5efcf4e42be01","user":{"login":"avocado-framework","id":7245719,"avatar_url":"https://avatars.githubusercontent.com/u/7245719?v=3","gravatar_id":"","url":"https://api.github.com/users/avocado-framework","html_url":"https://github.com/avocado-framework","followers_url":"https://api.github.com/users/avocado-framework/followers","following_url":"https://api.github.com/users/avocado-framework/following{/other_user}","gists_url":"https://api.github.com/users/avocado-framework/gists{/gist_id}","starred_url":"https://api.github.com/users/avocado-framework/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/avocado-framework/subscriptions","organizations_url":"https://api.github.com/users/avocado-framework/orgs","repos_url":"https://api.github.com/users/avocado-framework/repos","events_url":"https://api.github.com/users/avocado-framework/events{/privacy}","received_events_url":"https://api.github.com/users/avocado-framework/received_events","type":"Organization","site_admin":false},"repo":{"id":17449498,"name":"avocado","full_name":"avocado-framework/avocado","owner":{"login":"avocado-framework","id":7245719,"avatar_url":"https://avatars.githubusercontent.com/u/7245719?v=3","gravatar_id":"","url":"https://api.github.com/users/avocado-framework","html_url":"https://github.com/avocado-framework","followers_url":"https://api.github.com/users/avocado-framework/followers","following_url":"https://api.github.com/users/avocado-framework/following{/other_user}","gists_url":"https://api.github.com/users/avocado-framework/gists{/gist_id}","starred_url":"https://api.github.com/users/avocado-framework/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/avocado-framework/subscriptions","organizations_url":"https://api.github.com/users/avocado-framework/orgs","repos_url":"https://api.github.com/users/avocado-framework/repos","events_url":"https://api.github.com/users/avocado-framework/events{/privacy}","received_events_url":"https://api.github.com/users/avocado-framework/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/avocado-framework/avocado","description":"Avocado Test Framework","fork":false,"url":"https://api.github.com/repos/avocado-framework/avocado","forks_url":"https://api.github.com/repos/avocado-framework/avocado/forks","keys_url":"https://api.github.com/repos/avocado-framework/avocado/keys{/key_id}","collaborators_url":"https://api.github.com/repos/avocado-framework/avocado/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/avocado-framework/avocado/teams","hooks_url":"https://api.github.com/repos/avocado-framework/avocado/hooks","issue_events_url":"https://api.github.com/repos/avocado-framework/avocado/issues/events{/number}","events_url":"https://api.github.com/repos/avocado-framework/avocado/events","assignees_url":"https://api.github.com/repos/avocado-framework/avocado/assignees{/user}","branches_url":"https://api.github.com/repos/avocado-framework/avocado/branches{/branch}","tags_url":"https://api.github.com/repos/avocado-framework/avocado/tags","blobs_url":"https://api.github.com/repos/avocado-framework/avocado/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/avocado-framework/avocado/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/avocado-framework/avocado/git/refs{/sha}","trees_url":"https://api.github.com/repos/avocado-framework/avocado/git/trees{/sha}","statuses_url":"https://api.github.com/repos/avocado-framework/avocado/statuses/{sha}","languages_url":"https://api.github.com/repos/avocado-framework/avocado/languages","stargazers_url":"https://api.github.com/repos/avocado-framework/avocado/stargazers","contributors_url":"https://api.github.com/repos/avocado-framework/avocado/contributors","subscribers_url":"https://api.github.com/repos/avocado-framework/avocado/subscribers","subscription_url":"https://api.github.com/repos/avocado-framework/avocado/subscription","commits_url":"https://api.github.com/repos/avocado-framework/avocado/commits{/sha}","git_commits_url":"https://api.github.com/repos/avocado-framework/avocado/git/commits{/sha}","comments_url":"https://api.github.com/repos/avocado-framework/avocado/comments{/number}","issue_comment_url":"https://api.github.com/repos/avocado-framework/avocado/issues/comments/{number}","contents_url":"https://api.github.com/repos/avocado-framework/avocado/contents/{+path}","compare_url":"https://api.github.com/repos/avocado-framework/avocado/compare/{base}...{head}","merges_url":"https://api.github.com/repos/avocado-framework/avocado/merges","archive_url":"https://api.github.com/repos/avocado-framework/avocado/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/avocado-framework/avocado/downloads","issues_url":"https://api.github.com/repos/avocado-framework/avocado/issues{/number}","pulls_url":"https://api.github.com/repos/avocado-framework/avocado/pulls{/number}","milestones_url":"https://api.github.com/repos/avocado-framework/avocado/milestones{/number}","notifications_url":"https://api.github.com/repos/avocado-framework/avocado/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/avocado-framework/avocado/labels{/name}","releases_url":"https://api.github.com/repos/avocado-framework/avocado/releases{/id}","created_at":"2014-03-05T17:52:27Z","updated_at":"2015-01-22T18:03:53Z","pushed_at":"2015-01-22T18:03:53Z","git_url":"git://github.com/avocado-framework/avocado.git","ssh_url":"git@github.com:avocado-framework/avocado.git","clone_url":"https://github.com/avocado-framework/avocado.git","svn_url":"https://github.com/avocado-framework/avocado","homepage":"http://avocado-framework.github.io/","size":6207,"stargazers_count":17,"watchers_count":17,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":12,"mirror_url":null,"open_issues_count":11,"forks":12,"open_issues":11,"watchers":17,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/avocado-framework/avocado/pulls/342"},"html":{"href":"https://github.com/avocado-framework/avocado/pull/342"},"issue":{"href":"https://api.github.com/repos/avocado-framework/avocado/issues/342"},"comments":{"href":"https://api.github.com/repos/avocado-framework/avocado/issues/342/comments"},"review_comments":{"href":"https://api.github.com/repos/avocado-framework/avocado/pulls/342/comments"},"review_comment":{"href":"https://api.github.com/repos/avocado-framework/avocado/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/avocado-framework/avocado/pulls/342/commits"},"statuses":{"href":"https://api.github.com/repos/avocado-framework/avocado/statuses/fc08e35d81080db55874cfed16c22f2bd093a61c"}}}}