Closed
Description
Expected behavior
array_of_hashes
.flat_map(&:to_a)
.each_with_object({}) { |(k, v), h| (h[k] ||= []) << v }
$ ruby -c file.rb
Syntax OK
Actual behavior
array_of_hashes
.flat_map(&:to_a)
.each_with_object({}) { |(k, v), h| (h[k] ||= []) << v }
$ ruby -c file.rb
file.rb: file.rb:4: syntax error, unexpected '.' (SyntaxError)
.each_with_object({}) { |(k, v...
^
Steps to reproduce the problem
file.rb
:
array_of_hashes
.map(&:to_a)
.flatten(1)
.each_with_object({}) { |(k, v), h| (h[k] ||= []) << v }
rubocop --autocorrect-all --only Performance/FlatMap file.rb
RuboCop version
Include the output of rubocop -V
or bundle exec rubocop -V
if using Bundler. Here's an example:
You can see extension cop versions (e.g. rubocop-performance, rubocop-rails, and others) output by rubocop -V
,
include them as well. Here's an example:
$ [bundle exec] rubocop -V
1.45.1 (using Parser 3.2.1.0, rubocop-ast 1.26.0, running on ruby 3.2.0) [arm64-darwin21.5.0]
- rubocop-minitest 0.28.0
- rubocop-performance 1.16.0
- rubocop-rails 2.17.4
- rubocop-sorbet 0.6.8