Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Style/ClassAndModuleChildren style: namespace #9887

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from

Commits on Jun 21, 2021

  1. Add support for namespace and module definitions

    This adds support for a style wherein the concept of a module
    used as a namespace is kept separate from the definition of a
    class or module itself.
    
    Since the introduction of Zeitwerk in Rails the benefits of
    retaining the nested style in terms of accurate constant lookup have
    disappeared.
    
    This makes the compact style seem appealing for the following
    reasons:
    
    * Less low information value horizontal whitespace.
    * Less git churn when moving files around between differing namespace depths.
    * Easier scanning on the eyes when looking for the main constant.
    
    The compact style suffers slightly from the following though:
    * Main constant definition in a file is far over to the right in heavily namespaced files.
    * Change to either the namespace or the constant name results in change to the same line.
    
    The new proposed namespace style allows for
    * Conceptual separation of the namespace/package concept from the class or
       module definition.
    * File move refactors to a different namespace result in a diff that only touches
    the namespace constant part of the file.
    * Scanning by eye for the constant name is easier.
    
    ```ruby
    module Foo
      module Bar
        module Baz
          module Qux
            module Quux
              module Quuz
                module Corge
                  module Grault
                    module Garply
                      module Waldo
                        module Fred
                          class Plugh
                          end
                        end
                      end
                    end
                  end
                end
              end
            end
          end
        end
      end
    end
    ```
    
    ```ruby
    module Foo::Bar::Baz::Qux::Quux::Quuz::Corge::Grault::Garply::Waldo::Fred
      class Plugh
      end
    end
    ```
    
    ```ruby
    class Foo::Bar::Baz::Qux::Quux::Quuz::Corge::Grault::Garply::Waldo::Fred::Plugh
    end
    ```
    markburns committed Jun 21, 2021
    Configuration menu
    Copy the full SHA
    6a42d56 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    bd2f4d1 View commit details
    Browse the repository at this point in the history

Commits on Aug 27, 2022

  1. Configuration menu
    Copy the full SHA
    83806fe View commit details
    Browse the repository at this point in the history