-
-
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
SpaceInsideHashLiteralBraces fails on nested hashes #2595
Comments
So you are suggesting that there should be space inside a hash literal... unless the last value (or first key) is itself a hash? |
exactly. i adopted that style after seeing it used in really popular codebases (rails & mongoid off the top of my head). e.g. the following hashes would be valid
|
Guessing that the second should be
|
@jawshooah yup, updated it! thnx! |
i have also found instances from rspec where there is a hash argument in a Proc
lots of edge cases with this cop it seems... |
subject{ Foo.new({ foo: 'bar' }, type: :hash )} Examples don't give the whole picture. It better if you can express all rules that would define such a style. Something like:
There's a lot to be said for simple rules. It would be interesting to see these rules listed, but I'm not too keen on making things so complicated. |
@brewster1134 What do you think about cases where a hash literal appears inside a block, like this: method { |h| h.merge { key: val }} Do you prefer to see a space between the concluding braces, or not? |
@alexdowad the convention i have seen, would be just like how you have it. i think basically the rule is you always want to avoid @jonas054 when i have some time, i will sit down and define some specific rules (unless the examples above cover everything ha!). I just need to sit down and think it out... soon.... 😄 |
@alexdowad so after sitting down and writing out a variety of use cases, i think it should actually only apply to braces.
|
Can you suggest a name for this new style? We already have |
|
...As requested by Brewster. I personally also prefer this style on my own projects.
i noticed that a hash like
h = { a: 1, { b: 2 }}
will fail since it expectsh = { a: 1, { b: 2 } }
is this desired/standard style? i have always written it as the former. if the former should be allowed, i could take a stab at writing a spec for it (i am not familiar with this codebase however ;)
The text was updated successfully, but these errors were encountered: