-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
nested modules/classes syntax cop #868
Comments
Sounds like a good idea 👍 |
I'd accept such a cop if it were submitted. I might even write it, but given my workload these days that might not happen soon. |
Fell free to take a look at the new ClassAndModuleChildrenNested cop and let me know what you think about. |
Can anybody give a specific reason why the compact form is not preferred in the Ruby style guide? It seems like if you are keeping a single class per file it keeps the code closer to the left margin rather than indenting n levels deep based on the namespace structure. I've Googled and haven't come up with anything. What I'm looking for is a reason why I should consider moving to the longer style with more reasoning than that's the way Rails does it. |
@jonas054 👍 for the link. If anybody else finds this here is a gist that gives a working example regarding the tweet. |
I put links to many of the articles. I'm still not convinced that compact is incorrect so long as one properly namespaces constants, and classes, rather than depending on the default lookup rules, which i think could get ambiguous. http://forum.railsonmaui.com/t/ruby-linting-class-vs-lexical-scope/253 |
Basically there are two (or more) ways to nest modules/classes in ruby:
or
What do you think a about the idea of having a cop to check the syntax of nested modules/classes. Personally I would prefer the first one. I also heard, that it has some benefits and the ruby-style-guide only use the first one.
Maybe I'm able to write such a cop, but first I wanted to know what you think about this.
The text was updated successfully, but these errors were encountered: