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 unnecessary arguments for builtin methods. #7737
Comments
With static analysis, rubocop cannot determine if the receiver is array or string. So this will only work for literals like PS: I am willing to work on this if maintainers agree on the functionality. |
I think we should just assume that it's an array (or similar) type in case of
This cop would be in line with that. In most cases, for Only restricting this cop on literals or cases where we are 100% sure about the receiver would make this cop almost useless. So I would suggest just making the assumption that |
I think the request is fair. We should just make sure to mark it as unsafe. 👍 |
The default argument for This cop seems undesirable, as it is not redundant that blank string is specified as an explicit argument. |
I don't think so. So actually we can ignore |
Ah, I didn't know this deprecation warning. % rbenv local 2.6.5 && ruby -ve '$, = ","'
ruby 2.6.5p114 (2019-10-01 revision 67812) [x86_64-darwin17]
% rbenv local 2.7.0 && ruby -ve '$, = ","'
ruby 2.7.0p0 (2019-12-25 revision 647ee6f091) [x86_64-darwin17]
-e:1: warning: `$,' is deprecated Surely, it seems that blank string is fine for default argument. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contribution and understanding! |
This issues been automatically closed due to lack of activity. Feel free to re-open it if you ever come back to it. |
Is your feature request related to a problem? Please describe.
I found something like
array.join('')
in my code recently. This can of course be replaced byarray.join
. There is alsostring.split("\n")
orstring.gsub(a, '')
. I will try to collect more cases like this in this issue (help is welcome).Describe the solution you'd like
For a list of important builtin functions (e.g.
String#split
andArray#join
), if an argument is passed explicitly that leads to the same behavior as leaving the argument away, suggest to remove that argument.Additional context
Note that I might do this myself eventually. Depends on how much time I have and how eager someone else is to take it.
The text was updated successfully, but these errors were encountered: