{"action":"created","comment":{"url":"https://api.github.com/repos/asmcup/runtime/pulls/comments/87006438","pull_request_review_id":7633655,"id":87006438,"diff_hunk":"@@ -10,16 +12,27 @@ public Gene(byte[] dna, int gen, float score) {\n \t\tthis.gen = gen;\r\n \t\tthis.score = score;\r\n \t}\r\n-\t\r\n+\r\n+\t@Override\r\n \tpublic int compareTo(Gene other) {\r\n \t\tfloat d = score - other.score;\r\n \t\t\r\n-\t\tif (d == 0) {\r\n+\t\tif (Math.abs(d) < 0.00000001f) {\r\n \t\t\treturn 0;\r\n \t\t} else if (d < 0) {\r\n \t\t\treturn 1;\r\n \t\t}\r\n \t\t\r\n \t\treturn -1;\r\n \t}\r\n+\r\n+\t@Override\r\n+\tpublic boolean equals(Object obj) {\r\n+\t\treturn obj instanceof Gene && compareTo((Gene) obj) == 0;\r\n+\t}\r\n+\r\n+\t@Override\r\n+\tpublic int hashCode() {\r\n+\t\treturn Objects.hash(score);\r","path":"src/asmcup/genetics/Gene.java","position":35,"original_position":35,"commit_id":"d6416984aa69dc7d9fb6cf69d71f169d6e21a251","original_commit_id":"d6416984aa69dc7d9fb6cf69d71f169d6e21a251","user":{"login":"MLanghof","id":6524684,"avatar_url":"https://avatars.githubusercontent.com/u/6524684?v=3","gravatar_id":"","url":"https://api.github.com/users/MLanghof","html_url":"https://github.com/MLanghof","followers_url":"https://api.github.com/users/MLanghof/followers","following_url":"https://api.github.com/users/MLanghof/following{/other_user}","gists_url":"https://api.github.com/users/MLanghof/gists{/gist_id}","starred_url":"https://api.github.com/users/MLanghof/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MLanghof/subscriptions","organizations_url":"https://api.github.com/users/MLanghof/orgs","repos_url":"https://api.github.com/users/MLanghof/repos","events_url":"https://api.github.com/users/MLanghof/events{/privacy}","received_events_url":"https://api.github.com/users/MLanghof/received_events","type":"User","site_admin":false},"body":"Not quite. The default behavior (if I'm not mistaken) is that the object pointer is hashed (or something along those lines, point being that different [in the sense of \"not the exact same instance\"] objects usually have different hash codes and don't equal each other).\r\n\r\nThis means that the current implementation is [not consistent with equals](http://stackoverflow.com/questions/12123960/what-does-comparison-being-consistent-with-equals-mean-what-can-possibly-happe), but doesn't bog down e.g. a hash map.\r\n\r\nThe implication of this (to my understanding) is that (currently) asking a hash map for a `new Gene(score = z)` will return nothing, even though `new Gene(score = z).compareTo(g1)` would return true.\r\n\r\nThat's not a problem, because it's important to note that our genes must be sorted based on their score, but having the same score does not imply they are equal.","created_at":"2016-11-08T15:05:41Z","updated_at":"2016-11-08T15:05:41Z","html_url":"https://github.com/asmcup/runtime/pull/153#discussion_r87006438","pull_request_url":"https://api.github.com/repos/asmcup/runtime/pulls/153","_links":{"self":{"href":"https://api.github.com/repos/asmcup/runtime/pulls/comments/87006438"},"html":{"href":"https://github.com/asmcup/runtime/pull/153#discussion_r87006438"},"pull_request":{"href":"https://api.github.com/repos/asmcup/runtime/pulls/153"}}},"pull_request":{"url":"https://api.github.com/repos/asmcup/runtime/pulls/153","id":92657492,"html_url":"https://github.com/asmcup/runtime/pull/153","diff_url":"https://github.com/asmcup/runtime/pull/153.diff","patch_url":"https://github.com/asmcup/runtime/pull/153.patch","issue_url":"https://api.github.com/repos/asmcup/runtime/issues/153","number":153,"state":"open","locked":false,"title":"Fix bugs found by static analysis","user":{"login":"SiebelsTim","id":1153003,"avatar_url":"https://avatars.githubusercontent.com/u/1153003?v=3","gravatar_id":"","url":"https://api.github.com/users/SiebelsTim","html_url":"https://github.com/SiebelsTim","followers_url":"https://api.github.com/users/SiebelsTim/followers","following_url":"https://api.github.com/users/SiebelsTim/following{/other_user}","gists_url":"https://api.github.com/users/SiebelsTim/gists{/gist_id}","starred_url":"https://api.github.com/users/SiebelsTim/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SiebelsTim/subscriptions","organizations_url":"https://api.github.com/users/SiebelsTim/orgs","repos_url":"https://api.github.com/users/SiebelsTim/repos","events_url":"https://api.github.com/users/SiebelsTim/events{/privacy}","received_events_url":"https://api.github.com/users/SiebelsTim/received_events","type":"User","site_admin":false},"body":"this include:\r\n- Comparing float against equality\r\n- bad locking variables\r\n- relying on default charsets\r\n- compareTo, equal, hashCode discrepancies\r\n- using platform specific newline in printf\r\n\r\nI also included travis to run these and reports errors.\r\nOf course this will only be practical if there are no false positives.\r\nLet's see how good this works.","created_at":"2016-11-07T20:27:40Z","updated_at":"2016-11-08T15:07:00Z","closed_at":null,"merged_at":null,"merge_commit_sha":"c28f720ef9821e6ec412d84eb4134e57c89d4c9b","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/asmcup/runtime/pulls/153/commits","review_comments_url":"https://api.github.com/repos/asmcup/runtime/pulls/153/comments","review_comment_url":"https://api.github.com/repos/asmcup/runtime/pulls/comments{/number}","comments_url":"https://api.github.com/repos/asmcup/runtime/issues/153/comments","statuses_url":"https://api.github.com/repos/asmcup/runtime/statuses/d6416984aa69dc7d9fb6cf69d71f169d6e21a251","head":{"label":"SiebelsTim:findbugs","ref":"findbugs","sha":"d6416984aa69dc7d9fb6cf69d71f169d6e21a251","user":{"login":"SiebelsTim","id":1153003,"avatar_url":"https://avatars.githubusercontent.com/u/1153003?v=3","gravatar_id":"","url":"https://api.github.com/users/SiebelsTim","html_url":"https://github.com/SiebelsTim","followers_url":"https://api.github.com/users/SiebelsTim/followers","following_url":"https://api.github.com/users/SiebelsTim/following{/other_user}","gists_url":"https://api.github.com/users/SiebelsTim/gists{/gist_id}","starred_url":"https://api.github.com/users/SiebelsTim/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SiebelsTim/subscriptions","organizations_url":"https://api.github.com/users/SiebelsTim/orgs","repos_url":"https://api.github.com/users/SiebelsTim/repos","events_url":"https://api.github.com/users/SiebelsTim/events{/privacy}","received_events_url":"https://api.github.com/users/SiebelsTim/received_events","type":"User","site_admin":false},"repo":{"id":71378044,"name":"asmcupruntime","full_name":"SiebelsTim/asmcupruntime","owner":{"login":"SiebelsTim","id":1153003,"avatar_url":"https://avatars.githubusercontent.com/u/1153003?v=3","gravatar_id":"","url":"https://api.github.com/users/SiebelsTim","html_url":"https://github.com/SiebelsTim","followers_url":"https://api.github.com/users/SiebelsTim/followers","following_url":"https://api.github.com/users/SiebelsTim/following{/other_user}","gists_url":"https://api.github.com/users/SiebelsTim/gists{/gist_id}","starred_url":"https://api.github.com/users/SiebelsTim/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SiebelsTim/subscriptions","organizations_url":"https://api.github.com/users/SiebelsTim/orgs","repos_url":"https://api.github.com/users/SiebelsTim/repos","events_url":"https://api.github.com/users/SiebelsTim/events{/privacy}","received_events_url":"https://api.github.com/users/SiebelsTim/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/SiebelsTim/asmcupruntime","description":"Runtime and compiler for the Assembly Cup","fork":true,"url":"https://api.github.com/repos/SiebelsTim/asmcupruntime","forks_url":"https://api.github.com/repos/SiebelsTim/asmcupruntime/forks","keys_url":"https://api.github.com/repos/SiebelsTim/asmcupruntime/keys{/key_id}","collaborators_url":"https://api.github.com/repos/SiebelsTim/asmcupruntime/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/SiebelsTim/asmcupruntime/teams","hooks_url":"https://api.github.com/repos/SiebelsTim/asmcupruntime/hooks","issue_events_url":"https://api.github.com/repos/SiebelsTim/asmcupruntime/issues/events{/number}","events_url":"https://api.github.com/repos/SiebelsTim/asmcupruntime/events","assignees_url":"https://api.github.com/repos/SiebelsTim/asmcupruntime/assignees{/user}","branches_url":"https://api.github.com/repos/SiebelsTim/asmcupruntime/branches{/branch}","tags_url":"https://api.github.com/repos/SiebelsTim/asmcupruntime/tags","blobs_url":"https://api.github.com/repos/SiebelsTim/asmcupruntime/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/SiebelsTim/asmcupruntime/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/SiebelsTim/asmcupruntime/git/refs{/sha}","trees_url":"https://api.github.com/repos/SiebelsTim/asmcupruntime/git/trees{/sha}","statuses_url":"https://api.github.com/repos/SiebelsTim/asmcupruntime/statuses/{sha}","languages_url":"https://api.github.com/repos/SiebelsTim/asmcupruntime/languages","stargazers_url":"https://api.github.com/repos/SiebelsTim/asmcupruntime/stargazers","contributors_url":"https://api.github.com/repos/SiebelsTim/asmcupruntime/contributors","subscribers_url":"https://api.github.com/repos/SiebelsTim/asmcupruntime/subscribers","subscription_url":"https://api.github.com/repos/SiebelsTim/asmcupruntime/subscription","commits_url":"https://api.github.com/repos/SiebelsTim/asmcupruntime/commits{/sha}","git_commits_url":"https://api.github.com/repos/SiebelsTim/asmcupruntime/git/commits{/sha}","comments_url":"https://api.github.com/repos/SiebelsTim/asmcupruntime/comments{/number}","issue_comment_url":"https://api.github.com/repos/SiebelsTim/asmcupruntime/issues/comments{/number}","contents_url":"https://api.github.com/repos/SiebelsTim/asmcupruntime/contents/{+path}","compare_url":"https://api.github.com/repos/SiebelsTim/asmcupruntime/compare/{base}...{head}","merges_url":"https://api.github.com/repos/SiebelsTim/asmcupruntime/merges","archive_url":"https://api.github.com/repos/SiebelsTim/asmcupruntime/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/SiebelsTim/asmcupruntime/downloads","issues_url":"https://api.github.com/repos/SiebelsTim/asmcupruntime/issues{/number}","pulls_url":"https://api.github.com/repos/SiebelsTim/asmcupruntime/pulls{/number}","milestones_url":"https://api.github.com/repos/SiebelsTim/asmcupruntime/milestones{/number}","notifications_url":"https://api.github.com/repos/SiebelsTim/asmcupruntime/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/SiebelsTim/asmcupruntime/labels{/name}","releases_url":"https://api.github.com/repos/SiebelsTim/asmcupruntime/releases{/id}","deployments_url":"https://api.github.com/repos/SiebelsTim/asmcupruntime/deployments","created_at":"2016-10-19T16:39:13Z","updated_at":"2016-10-22T09:08:20Z","pushed_at":"2016-11-07T20:27:28Z","git_url":"git://github.com/SiebelsTim/asmcupruntime.git","ssh_url":"git@github.com:SiebelsTim/asmcupruntime.git","clone_url":"https://github.com/SiebelsTim/asmcupruntime.git","svn_url":"https://github.com/SiebelsTim/asmcupruntime","homepage":"https://asmcup.github.io","size":322,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":true,"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":"asmcup:master","ref":"master","sha":"5d4c8c1def06480f9bb7c44e1ed4291790518341","user":{"login":"asmcup","id":22485127,"avatar_url":"https://avatars.githubusercontent.com/u/22485127?v=3","gravatar_id":"","url":"https://api.github.com/users/asmcup","html_url":"https://github.com/asmcup","followers_url":"https://api.github.com/users/asmcup/followers","following_url":"https://api.github.com/users/asmcup/following{/other_user}","gists_url":"https://api.github.com/users/asmcup/gists{/gist_id}","starred_url":"https://api.github.com/users/asmcup/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/asmcup/subscriptions","organizations_url":"https://api.github.com/users/asmcup/orgs","repos_url":"https://api.github.com/users/asmcup/repos","events_url":"https://api.github.com/users/asmcup/events{/privacy}","received_events_url":"https://api.github.com/users/asmcup/received_events","type":"Organization","site_admin":false},"repo":{"id":70013675,"name":"runtime","full_name":"asmcup/runtime","owner":{"login":"asmcup","id":22485127,"avatar_url":"https://avatars.githubusercontent.com/u/22485127?v=3","gravatar_id":"","url":"https://api.github.com/users/asmcup","html_url":"https://github.com/asmcup","followers_url":"https://api.github.com/users/asmcup/followers","following_url":"https://api.github.com/users/asmcup/following{/other_user}","gists_url":"https://api.github.com/users/asmcup/gists{/gist_id}","starred_url":"https://api.github.com/users/asmcup/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/asmcup/subscriptions","organizations_url":"https://api.github.com/users/asmcup/orgs","repos_url":"https://api.github.com/users/asmcup/repos","events_url":"https://api.github.com/users/asmcup/events{/privacy}","received_events_url":"https://api.github.com/users/asmcup/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/asmcup/runtime","description":"Runtime and compiler for the Assembly Cup","fork":false,"url":"https://api.github.com/repos/asmcup/runtime","forks_url":"https://api.github.com/repos/asmcup/runtime/forks","keys_url":"https://api.github.com/repos/asmcup/runtime/keys{/key_id}","collaborators_url":"https://api.github.com/repos/asmcup/runtime/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/asmcup/runtime/teams","hooks_url":"https://api.github.com/repos/asmcup/runtime/hooks","issue_events_url":"https://api.github.com/repos/asmcup/runtime/issues/events{/number}","events_url":"https://api.github.com/repos/asmcup/runtime/events","assignees_url":"https://api.github.com/repos/asmcup/runtime/assignees{/user}","branches_url":"https://api.github.com/repos/asmcup/runtime/branches{/branch}","tags_url":"https://api.github.com/repos/asmcup/runtime/tags","blobs_url":"https://api.github.com/repos/asmcup/runtime/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/asmcup/runtime/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/asmcup/runtime/git/refs{/sha}","trees_url":"https://api.github.com/repos/asmcup/runtime/git/trees{/sha}","statuses_url":"https://api.github.com/repos/asmcup/runtime/statuses/{sha}","languages_url":"https://api.github.com/repos/asmcup/runtime/languages","stargazers_url":"https://api.github.com/repos/asmcup/runtime/stargazers","contributors_url":"https://api.github.com/repos/asmcup/runtime/contributors","subscribers_url":"https://api.github.com/repos/asmcup/runtime/subscribers","subscription_url":"https://api.github.com/repos/asmcup/runtime/subscription","commits_url":"https://api.github.com/repos/asmcup/runtime/commits{/sha}","git_commits_url":"https://api.github.com/repos/asmcup/runtime/git/commits{/sha}","comments_url":"https://api.github.com/repos/asmcup/runtime/comments{/number}","issue_comment_url":"https://api.github.com/repos/asmcup/runtime/issues/comments{/number}","contents_url":"https://api.github.com/repos/asmcup/runtime/contents/{+path}","compare_url":"https://api.github.com/repos/asmcup/runtime/compare/{base}...{head}","merges_url":"https://api.github.com/repos/asmcup/runtime/merges","archive_url":"https://api.github.com/repos/asmcup/runtime/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/asmcup/runtime/downloads","issues_url":"https://api.github.com/repos/asmcup/runtime/issues{/number}","pulls_url":"https://api.github.com/repos/asmcup/runtime/pulls{/number}","milestones_url":"https://api.github.com/repos/asmcup/runtime/milestones{/number}","notifications_url":"https://api.github.com/repos/asmcup/runtime/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/asmcup/runtime/labels{/name}","releases_url":"https://api.github.com/repos/asmcup/runtime/releases{/id}","deployments_url":"https://api.github.com/repos/asmcup/runtime/deployments","created_at":"2016-10-04T23:06:27Z","updated_at":"2016-11-07T03:17:10Z","pushed_at":"2016-11-07T20:27:40Z","git_url":"git://github.com/asmcup/runtime.git","ssh_url":"git@github.com:asmcup/runtime.git","clone_url":"https://github.com/asmcup/runtime.git","svn_url":"https://github.com/asmcup/runtime","homepage":"https://asmcup.github.io","size":370,"stargazers_count":143,"watchers_count":143,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":12,"mirror_url":null,"open_issues_count":13,"forks":12,"open_issues":13,"watchers":143,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/asmcup/runtime/pulls/153"},"html":{"href":"https://github.com/asmcup/runtime/pull/153"},"issue":{"href":"https://api.github.com/repos/asmcup/runtime/issues/153"},"comments":{"href":"https://api.github.com/repos/asmcup/runtime/issues/153/comments"},"review_comments":{"href":"https://api.github.com/repos/asmcup/runtime/pulls/153/comments"},"review_comment":{"href":"https://api.github.com/repos/asmcup/runtime/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/asmcup/runtime/pulls/153/commits"},"statuses":{"href":"https://api.github.com/repos/asmcup/runtime/statuses/d6416984aa69dc7d9fb6cf69d71f169d6e21a251"}}}}
{"actor":{"display_login":"MLanghof"}}