-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Replace -> (...) with ->(...) to be Ruby 1.9.3 compatible
#313
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
Conversation
|
I'm ok with this, but I think we should add some kind of safeguard to prevent these from slipping back in as files are changed. Otherwise, I'll forget, and start adding more What do you think about adding something to the unit tests that makes sure this rule is followed? It would be ok with me to do something like: it "uses 1.9.3-compatible stabby literals" do
invalid_stabby_pattern = /->\s+\(/
assert_project_files_dont_match(invalid_stabby_pattern)
end (Implementing Or, if you have another suggestion, I'm open to something else! I just don't trust myself to remember this style. |
|
Alternatively, is this transform predictable enough to be maintained as a git hook? I mean, if it's a "simple" find and replace, maybe it wouldn't be so bad to maintain it on the 1.9.3 branch. Just a thought, I'm not a git hook user so I can't really take it farther than that :P |
13fc4ed to
0b61309
Compare
Fine by me.
Well, until we enforce that, me rebasing the
I could do that as a fallback solution, but I don't want to cloud your test suite with something like that.
I looked a bit, and it seems to me that 99% of the web uses
This doesn't seem very idiomatic in Ruby so I'd rather fix it upstream. Plus I don't know if this is compatible with all implementations of Ruby, such as JRuby.
Probably, but git hooks are not server side, and they aren't added to the repo, so any contributor would need to have the hook, definitely not something we can do. Let's wait and see for what the Rubocop guys have to say about this. In the meantime, I am happy to periodically check for this should you decide to merge this without enforcing it automatically. |
|
@rmosolgo, author of RuboCop and the Ruby style guide agreed keeping the style without space is better on rubocop/rubocop#3631. Mind merging this then? If no one is creating a cop for this, I'll look into how to do that myself when I have a bit of time. |
|
👍 cool, I'm happy to just do my best for the time being! I guess I picked up habits for |
See http://ruby-journal.com/becareful-with-space-in-lambda-hash-rocket-syntax-between-ruby-1-dot-9-and-2-dot-0/ for more info.
Extracted from #306 which will be easier to maintain without that commit.
Note that this is also how http://www.rubydoc.info/gems/rubocop/RuboCop/Cop/Style/Lambda defines lambdas like this as well.