{"action":"created","issue":{"url":"https://api.github.com/repos/bbatsov/rubocop/issues/3724","repository_url":"https://api.github.com/repos/bbatsov/rubocop","labels_url":"https://api.github.com/repos/bbatsov/rubocop/issues/3724/labels{/name}","comments_url":"https://api.github.com/repos/bbatsov/rubocop/issues/3724/comments","events_url":"https://api.github.com/repos/bbatsov/rubocop/issues/3724/events","html_url":"https://github.com/bbatsov/rubocop/pull/3724","id":189807792,"number":3724,"title":"[Fix #3723] Add new Rails/EnumUniqueness cop.","user":{"login":"olliebennett","id":1068525,"avatar_url":"https://avatars.githubusercontent.com/u/1068525?v=3","gravatar_id":"","url":"https://api.github.com/users/olliebennett","html_url":"https://github.com/olliebennett","followers_url":"https://api.github.com/users/olliebennett/followers","following_url":"https://api.github.com/users/olliebennett/following{/other_user}","gists_url":"https://api.github.com/users/olliebennett/gists{/gist_id}","starred_url":"https://api.github.com/users/olliebennett/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/olliebennett/subscriptions","organizations_url":"https://api.github.com/users/olliebennett/orgs","repos_url":"https://api.github.com/users/olliebennett/repos","events_url":"https://api.github.com/users/olliebennett/events{/privacy}","received_events_url":"https://api.github.com/users/olliebennett/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2016-11-16T18:57:15Z","updated_at":"2016-11-21T10:47:03Z","closed_at":"2016-11-21T10:41:23Z","pull_request":{"url":"https://api.github.com/repos/bbatsov/rubocop/pulls/3724","html_url":"https://github.com/bbatsov/rubocop/pull/3724","diff_url":"https://github.com/bbatsov/rubocop/pull/3724.diff","patch_url":"https://github.com/bbatsov/rubocop/pull/3724.patch"},"body":"A new `Rails/EnumUniqueness` cop which identifies any (presumably accidental) usage of duplicate `enum` value definitions.\r\n\r\n```ruby\r\n# bad\r\nenum status: { active: 4, archived: 4 }\r\n```\r\n\r\nMore details in issue #3723.\r\n\r\nThis is functional (and tested), but probably not the best approach. I'm open to feedback around any shortcuts / simplifications / alternative approaches / other cops to take inspiration from - specifically around my (somewhat clunky) handling of args passed to `enum` via `RuboCop::Node`. I'm also open to alternative names for this cop.\r\n\r\n-----------------\r\n\r\nBefore submitting the PR make sure the following are checked:\r\n\r\n* [x] Wrote [good commit messages][1].\r\n* [x] Commit message starts with `[Fix #issue-number]` (if the related issue exists).\r\n* [ ] Used the same coding conventions as the rest of the project.\r\n* [x] Feature branch is up-to-date with `master` (if not - rebase it).\r\n* [x] Squashed related commits together.\r\n* [x] Added tests.\r\n* [x] Added an entry to the [Changelog](../blob/master/CHANGELOG.md) if the new code introduces user-observable changes. See [changelog entry format](../blob/master/CONTRIBUTING.md#changelog-entry-format).\r\n* [x] All tests are passing.\r\n* [x] The new code doesn't generate RuboCop offenses.\r\n* [x] The PR relates to *only* one subject with a clear title\r\n  and description in grammatically correct, complete sentences.\r\n* [x] Updated cop documentation with `rake generate_cops_documentation` (required only when you've added a new cop or changed the configuration/documentation of an existing cop).\r\n\r\n[1]: http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html\r\n"},"comment":{"url":"https://api.github.com/repos/bbatsov/rubocop/issues/comments/261904044","html_url":"https://github.com/bbatsov/rubocop/pull/3724#issuecomment-261904044","issue_url":"https://api.github.com/repos/bbatsov/rubocop/issues/3724","id":261904044,"user":{"login":"olliebennett","id":1068525,"avatar_url":"https://avatars.githubusercontent.com/u/1068525?v=3","gravatar_id":"","url":"https://api.github.com/users/olliebennett","html_url":"https://github.com/olliebennett","followers_url":"https://api.github.com/users/olliebennett/followers","following_url":"https://api.github.com/users/olliebennett/following{/other_user}","gists_url":"https://api.github.com/users/olliebennett/gists{/gist_id}","starred_url":"https://api.github.com/users/olliebennett/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/olliebennett/subscriptions","organizations_url":"https://api.github.com/users/olliebennett/orgs","repos_url":"https://api.github.com/users/olliebennett/repos","events_url":"https://api.github.com/users/olliebennett/events{/privacy}","received_events_url":"https://api.github.com/users/olliebennett/received_events","type":"User","site_admin":false},"created_at":"2016-11-21T10:47:03Z","updated_at":"2016-11-21T10:47:03Z","body":"Good point. Rails at least catches that (albeit indirectly and confusingly) as follows:\r\n\r\n> /Users/ollie/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activerecord-4.2.7.1/lib/active_record/enum.rb:187:in `detect_enum_conflict!': You tried to define an enum named \"status\" on the model \"User\", but this will generate a instance method \"ala?\", which is already defined by another enum. (ArgumentError)\r\n\r\nIt would make sense to catch at Rubocop stage though. Will enhance this cop when I get a moment."}}
{"actor":{"display_login":"olliebennett"}}