-
-
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
Remove trailing named variables #2246
Remove trailing named variables #2246
Conversation
31b6813
to
cf71a68
Compare
I forgot to add some of the performance notes about this PR. When running my normal memory profile on It is also faster to not assign underscore variables ARRAY = *1..10
def with_trailing
a, b, c, d, e, *_f = *ARRAY
nil
end
def without_trailing
a, b, c, d, e, = *ARRAY
nil
end
Benchmark.ips do |x|
x.report('with trailing') { with_trailing }
x.report('without trailing') { without_trailing }
x.compare!
end
|
39a835d
to
fba0319
Compare
Sorry that I'm responding to this PR just now. Was a bit short on time and wanted to push a bugfix only release before starting to merge new features, anyways. My biggest doubt is what should be default now that the cop is configurable. I'd love to hear what other think about this. |
It is fine that it took a while to comment. I realize that this is a rather large commit and goes against the original design of this cop. I debated as to whether the configuration should be defaulted to on, or defaulted to off and turned on for this project.
I agree with you that it is useful to know the structure of the node. A vast majority of the |
I am fine with leaving the |
That'd be great. |
3fd9fa7
to
c633cae
Compare
I changed the configuration name to |
29da4a7
to
b963907
Compare
This has to be rebased. |
…erscore variables
…y a splat variable
b963907
to
a7706fa
Compare
The code has been rebased. |
Remove trailing named variables
👍 |
This turned into a larger commit than I originally thought it would be.
There are 3 modification to
Style/TrailingUnderscorevariable
.*_
a, *b, = foo()
is a syntax error