You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I would expect RuboCop to suggest flat_map for 1., 2., and 3.
Output:
Inspecting 1 file
C
Offenses:
test.rb:3:13: C: Performance/FlatMap: Use flat_map instead of map...flatten.
p [1, 2, 3].map { |x| x.digits }.flatten(1)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
test.rb:3:17: C: Style/SymbolProc: Pass &:digits as an argument to map instead of a block.
p [1, 2, 3].map { |x| x.digits }.flatten(1)
^^^^^^^^^^^^^^^^
test.rb:4:13: C: Performance/FlatMap: Use flat_map instead of map...flatten.
p [1, 2, 3].map(&:digits).flatten(1)
^^^^^^^^^^^^^^^^^^^^^^^^
test.rb:7:13: C: Performance/FlatMap: Use flat_map instead of map...flatten.
p [1, 2, 3].map(&digits).flatten(1)
^^^^^^^^^^^^^^^^^^^^^^^
1 file inspected, 4 offenses detected
Actual behavior
RuboCop only suggests flat_map for 1.
Output:
Inspecting 1 file
C
Offenses:
test.rb:3:13: C: Performance/FlatMap: Use flat_map instead of map...flatten.
p [1, 2, 3].map { |x| x.digits }.flatten(1)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
test.rb:3:17: C: Style/SymbolProc: Pass &:digits as an argument to map instead of a block.
p [1, 2, 3].map { |x| x.digits }.flatten(1)
^^^^^^^^^^^^^^^^
1 file inspected, 2 offenses detected
Expected behavior
Given a test file
test.rb
:I would expect RuboCop to suggest
flat_map
for 1., 2., and 3.Output:
Actual behavior
RuboCop only suggests
flat_map
for 1.Output:
Steps to reproduce the problem
Run
rubocop -C false test.rb
RuboCop version
Suggested solultion
This patch below works as expected.
The text was updated successfully, but these errors were encountered: