{"action":"created","issue":{"url":"https://api.github.com/repos/bbatsov/rubocop/issues/1342","labels_url":"https://api.github.com/repos/bbatsov/rubocop/issues/1342/labels{/name}","comments_url":"https://api.github.com/repos/bbatsov/rubocop/issues/1342/comments","events_url":"https://api.github.com/repos/bbatsov/rubocop/issues/1342/events","html_url":"https://github.com/bbatsov/rubocop/issues/1342","id":43448419,"number":1342,"title":"Rails-compatible indentation of private and protected methods","user":{"login":"grn","id":90490,"avatar_url":"https://avatars.githubusercontent.com/u/90490?v=3","gravatar_id":"","url":"https://api.github.com/users/grn","html_url":"https://github.com/grn","followers_url":"https://api.github.com/users/grn/followers","following_url":"https://api.github.com/users/grn/following{/other_user}","gists_url":"https://api.github.com/users/grn/gists{/gist_id}","starred_url":"https://api.github.com/users/grn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/grn/subscriptions","organizations_url":"https://api.github.com/users/grn/orgs","repos_url":"https://api.github.com/users/grn/repos","events_url":"https://api.github.com/users/grn/events{/privacy}","received_events_url":"https://api.github.com/users/grn/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2014-09-22T09:20:02Z","updated_at":"2015-02-01T20:02:39Z","closed_at":null,"body":"# Problem\r\n\r\nCurrently Rubocop can check the indentation of `private`, `protected` and `public` modifiers. Unfortunately it isn't able to check whether the code that follows uses the Rails convention of indenting private and protected methods with respect to `private` and `protected`. For example the style\r\n\r\n```ruby\r\nclass MyClass\r\n  def a_public_method\r\n  end\r\n\r\n  private\r\n\r\n    def a_private_method\r\n    end\r\nend\r\n```\r\n\r\nshould be supported.\r\n\r\n# Solution\r\n\r\nThe `Style/AccessModifierIndentation` cop could support a new `EnforcedStyle` called `rails` that would use the Rails convention.\r\n\r\n`rubocop -V` returns\r\n\r\n```\r\n0.26.1 (using Parser 2.2.0.pre.4, running on ruby 2.0.0 x86_64-linux)\r\n```"},"comment":{"url":"https://api.github.com/repos/bbatsov/rubocop/issues/comments/72381271","html_url":"https://github.com/bbatsov/rubocop/issues/1342#issuecomment-72381271","issue_url":"https://api.github.com/repos/bbatsov/rubocop/issues/1342","id":72381271,"user":{"login":"Proghat","id":800337,"avatar_url":"https://avatars.githubusercontent.com/u/800337?v=3","gravatar_id":"","url":"https://api.github.com/users/Proghat","html_url":"https://github.com/Proghat","followers_url":"https://api.github.com/users/Proghat/followers","following_url":"https://api.github.com/users/Proghat/following{/other_user}","gists_url":"https://api.github.com/users/Proghat/gists{/gist_id}","starred_url":"https://api.github.com/users/Proghat/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Proghat/subscriptions","organizations_url":"https://api.github.com/users/Proghat/orgs","repos_url":"https://api.github.com/users/Proghat/repos","events_url":"https://api.github.com/users/Proghat/events{/privacy}","received_events_url":"https://api.github.com/users/Proghat/received_events","type":"User","site_admin":false},"created_at":"2015-02-01T20:02:39Z","updated_at":"2015-02-01T20:02:39Z","body":"I would like to implement this. In my style guide it may looks like:\r\n\r\n1. Don't use explicit `public` access modifier. Keep all public methods on top of class defenition.\r\n2. Write `protected` and `private` keywords in the same level of indentation as public methods.\r\n3. Indent protected and private methods relative to `protected` and `private` keywords.\r\n\r\nExample:\r\n\r\n```ruby\r\nclass Cat\r\n  def meow\r\n    puts('Meow!')\r\n  end\r\n\r\n  protected\r\n\r\n    def can_we_be_friends?(another_cat)\r\n      # some logic\r\n    end\r\n\r\n  private\r\n\r\n    def meow_at_3am?\r\n      rand < 0.8\r\n    end\r\nend\r\n```\r\n\r\nAs I understand changes could affect `Cop::Style::IndentationConsistency` and `Cop::Style::IndentationWidth`. I'm not sure where to store config for this. I think about:\r\n```yaml\r\nStyle/IndentationConsistency:\r\n  AllowProtectedAndPrivateMethodsBeIndented: true\r\n```\r\nbut is it ok if I will check this config in `IndentationWidth` cop?\r\n\r\n@bbatsov can you please help me? Will it be merged?"}}