Expected behavior
Currently, RuboCop suggest to correct expressions like
%w[a* b*].map { |e| Dir.glob(e) }.reduce(&:+)
to
%w[a* b*].map { |e| Dir.glob(e) }.sum
Since Dir.glob is known to return an array we can autocorrect to sum([]) instead. This can be generalized to other stdlib methods returning arrays
Actual behavior
Unsafe autocorrection is %w[a* b*].map { |e| Dir.glob(e) }.sum, which is invalid.
Steps to reproduce the problem
N/A
RuboCop version
main
Expected behavior
Currently, RuboCop suggest to correct expressions like
to
Since
Dir.globis known to return an array we can autocorrect tosum([])instead. This can be generalized to other stdlib methods returning arraysActual behavior
Unsafe autocorrection is
%w[a* b*].map { |e| Dir.glob(e) }.sum, which is invalid.Steps to reproduce the problem
N/A
RuboCop version
main