{"action":"created","issue":{"url":"https://api.github.com/repos/bbatsov/rubocop/issues/3803","repository_url":"https://api.github.com/repos/bbatsov/rubocop","labels_url":"https://api.github.com/repos/bbatsov/rubocop/issues/3803/labels{/name}","comments_url":"https://api.github.com/repos/bbatsov/rubocop/issues/3803/comments","events_url":"https://api.github.com/repos/bbatsov/rubocop/issues/3803/events","html_url":"https://github.com/bbatsov/rubocop/issues/3803","id":196547779,"number":3803,"title":"Style/AlignHash conflicts with Style/AlignParameters","user":{"login":"adamgotterer","id":223498,"avatar_url":"https://avatars.githubusercontent.com/u/223498?v=3","gravatar_id":"","url":"https://api.github.com/users/adamgotterer","html_url":"https://github.com/adamgotterer","followers_url":"https://api.github.com/users/adamgotterer/followers","following_url":"https://api.github.com/users/adamgotterer/following{/other_user}","gists_url":"https://api.github.com/users/adamgotterer/gists{/gist_id}","starred_url":"https://api.github.com/users/adamgotterer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adamgotterer/subscriptions","organizations_url":"https://api.github.com/users/adamgotterer/orgs","repos_url":"https://api.github.com/users/adamgotterer/repos","events_url":"https://api.github.com/users/adamgotterer/events{/privacy}","received_events_url":"https://api.github.com/users/adamgotterer/received_events","type":"User","site_admin":false},"labels":[{"id":3608332,"url":"https://api.github.com/repos/bbatsov/rubocop/labels/bug","name":"bug","color":"fc2929","default":true}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2016-12-19T23:31:13Z","updated_at":"2017-01-01T08:29:03Z","closed_at":null,"body":"## Expected behavior\r\n\r\nGiven the following .rubocop.yml and method call I expected there not to be a Style/AlignHash error.\r\n\r\n```\r\n# .rubocop.yml\r\nStyle/AlignParameters:\r\n  EnforcedStyle: with_first_parameter\r\n\r\nStyle/AlignHash:\r\n  EnforcedHashRocketStyle: key\r\n```\r\n\r\n```ruby\r\nsomemethod(a: 'val'\r\n  b: 'val1')\r\n```\r\n\r\n## Actual behavior\r\n\r\n`Style/AlignHash: Align the elements of a hash literal if they span more than one line`. It seems that if the parameters are a hash that it uses AlignHash instead of AlignParameters. As best I can tell there isn't any alignment settings that can be set in AlignHash?\r\n\r\n## RuboCop version\r\n\r\n0.46.0 (using Parser 2.3.3.1, running on ruby 2.3.1 x86_64-linux)\r\n"},"comment":{"url":"https://api.github.com/repos/bbatsov/rubocop/issues/comments/269895669","html_url":"https://github.com/bbatsov/rubocop/issues/3803#issuecomment-269895669","issue_url":"https://api.github.com/repos/bbatsov/rubocop/issues/3803","id":269895669,"user":{"login":"jonas054","id":336720,"avatar_url":"https://avatars.githubusercontent.com/u/336720?v=3","gravatar_id":"","url":"https://api.github.com/users/jonas054","html_url":"https://github.com/jonas054","followers_url":"https://api.github.com/users/jonas054/followers","following_url":"https://api.github.com/users/jonas054/following{/other_user}","gists_url":"https://api.github.com/users/jonas054/gists{/gist_id}","starred_url":"https://api.github.com/users/jonas054/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jonas054/subscriptions","organizations_url":"https://api.github.com/users/jonas054/orgs","repos_url":"https://api.github.com/users/jonas054/repos","events_url":"https://api.github.com/users/jonas054/events{/privacy}","received_events_url":"https://api.github.com/users/jonas054/received_events","type":"User","site_admin":false},"created_at":"2017-01-01T08:29:03Z","updated_at":"2017-01-01T08:29:03Z","body":"So the problem is that the configuration\r\n```yaml\r\nStyle/AlignParameters:\r\n  EnforcedStyle: with_fixed_indentation\r\n```\r\ngives the inconsistency\r\n```ruby\r\nsomemethod(a: 'val'\r\n           b: 'val1')\r\nsomemethod('val'\r\n  'val1')\r\n```\r\nWe could let `Style/AlignHash` leave the inspection of braceless hash arguments to `Style/AlignParameters`, meaning that we view the elements as individual keyword arguments rather than key/value pairs in a hash. That would give us\r\n```ruby\r\nsomemethod(a: 'val'\r\n  b: 'val1')\r\nsomemethod('val'\r\n  'val1')\r\n```\r\nwhich I guess is more consistent and logical. The only problem I foresee is that the configuration\r\n```yaml\r\nStyle/AlignParameters:\r\n  EnforcedStyle: with_first_parameter\r\n\r\nStyle/AlignHash:\r\n  EnforcedColonStyle: table\r\n```\r\nwhich today gives\r\n```ruby\r\nsomemethod(a:    'val'\r\n           bbbb: 'val1')\r\nhash = {\r\n  a:    'val'\r\n  bbbb: 'val1')\r\n}\r\n```\r\nwould give\r\n```ruby\r\nsomemethod(a: 'val'\r\n           bbbb: 'val1')\r\nhash = {\r\n  a:    'val'\r\n  bbbb: 'val1')\r\n}\r\n```\r\ni.e., you wouldn't be able to have `table` (or `separator`) alignment in method calls.\r\n\r\nSo it's a tradeoff. I'm leaning towards making the change, but don't have a strong opinion.\r\n\r\nOr is there another solution where we cold have the cake and eat it too?"}}
{"actor":{"display_login":"jonas054"}}