standardrb/standard

Was indented_internal_methods considered?

duduribeiro opened this issue ยท 2 comments

Hey folks ๐Ÿ‘‹

Quick question: Did the team already considered enforcing Layout/IndentationConsistency with indented_internal_methods?

I know this is a polemic topic but I kind like the way indented_internal_methods https://www.rubydoc.info/gems/rubocop/RuboCop/Cop/Layout/IndentationConsistency works when navigating through the source code ๐Ÿ˜„

# good
class A
  def test
    puts 'hello'
    puts 'world'
  end

  protected

    def foo
    end

  private

    def bar
    end
end

did standard ever considered this option or this is a definitely a non go?

thanks a lot

searls commented

We did consider this rule when we first started work on Standard and decided against it.

The primary reason is that public/protected/private labels do not denote actual nested constructs (like classes, blocks, if-else/case statements, or method definitions) and therefore it isn't consistent to indent them as if they were. They're really just class methods that mutate a class's state such that the specified modifier will be applied as the visibility to all subsequently-defined methods until another visibility modifier class method is invoked.

amazing. thanks for answering it @searls

agree with you