Seems Style/RedundantArgument didn't know about second argument limit for split method
test.rb script with content:foo = 'a b c d e'
bar = foo.split(' ', 2)
puts(bar[0] == 'a')
puts(bar[1] == 'b c d e')
rubocop -A test.rb
Inspecting 1 file
C
Offenses:
test.rb:2:7: C: Style/RedundantArgument: Argument ' ' is redundant because it is implied by default.
bar = foo.split(' ', 2)
^^^^^^^^^^^^^^^^^
1 file inspected, 1 offense detected
Seems in that case this cop should just ignore it, if limit is set
rubocop -V
1.4.0 (using Parser 2.7.2.0, rubocop-ast 1.1.1, running on ruby 2.7.2 x86_64-linux)
- rubocop-performance 1.9.0
- rubocop-rspec 2.0.0
The cop was supposed ignore method calls with more than 1 argument, but I guess the check and the test case is missing. //cc @tejasbubane
The cop was supposed ignore method calls with more than 1 argument, but I guess the check and the test case is missing. //cc @tejasbubane
Right I missed that check.
Hi.
It seems like the fix did not make it into the 1.4.1 release, although it is listed in the CHANGELOG:
https://github.com/rubocop-hq/rubocop/blob/master/CHANGELOG.md#141-2020-11-23
I just hit this problem with 1.4.1:
Resolving dependencies...
...
Using rake 13.0.1
Fetching rubocop 1.4.1
...
lib/colorls/git.rb:19:24: C: Style/RedundantArgument: Argument ' ' is redundant because it is implied by default.
mode, file = status_line.chomp("\x0").split(' ', 2)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@avdv Right. This bug came in just after 1.4.1 was released. The fix has been merged but will be released in the next version.
@avdv Right. This bug came in just after
1.4.1was released. The fix has been merged but will be released in the next version.
It's just that I am using depend-a-bot which sources the changelog from the changelog.md file of a gem's repository and hitting the same bug it says is fixed on the tin is ... surprising. :smile:
Waiting for the next release then.
@avdv Ok something seems wrong with the changelog. Commits here show Cut 1.4.1 before merging this PR.
cc @bbatsov
Yeah, it seems I didn't notice that the changelog entry was misplaced. That's why these days it's discouraged to edit the changelog directly and we're mostly generating it from the files under changelog/. I've fixed it now.