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
With a line like File.join(Rails.root, %w[test files migration]) with an array, it should be either
A. be ignored or
B. turned into Rails.root.join('test', 'files', 'migration').to_s
Personally, I prefer the notation with %w to minimize quotes. Thus I wouild choose option A, but I suspect gem author prefers B, which is acceptable.
Actual behavior
Running Rails/FilePath cop on File.join(Rails.root, %w[test files migration]) turns into Rails.root.join(%w[test files migration]).to_s, which Pathname.join can't handle array
$ docker-compose exec web ruby tmp/test.rb
/usr/local/lib/ruby/3.3.0/pathname.rb:419:in `initialize': no implicit conversion of Array into String (TypeError)
result = Pathname.new(result) unless Pathname === result
^^^^^^
from /usr/local/lib/ruby/3.3.0/pathname.rb:419:in `new'
from /usr/local/lib/ruby/3.3.0/pathname.rb:419:in `join'
from tmp/test.rb:2:in `<main>'
RuboCop version
$ docker-compose exec web rubocop --verbose-version
1.69.0 (using Parser 3.3.6.0, rubocop-ast 1.36.2, analyzing as Ruby 3.3, running on ruby 3.3.6) [x86_64-linux-musl]
- rubocop-performance 1.23.0
- rubocop-rails 2.27.0
Expected behavior
With a line like
File.join(Rails.root, %w[test files migration])
with an array, it should be eitherA. be ignored or
B. turned into
Rails.root.join('test', 'files', 'migration').to_s
Personally, I prefer the notation with %w to minimize quotes. Thus I wouild choose option A, but I suspect gem author prefers B, which is acceptable.
Actual behavior
Running
Rails/FilePath
cop onFile.join(Rails.root, %w[test files migration])
turns intoRails.root.join(%w[test files migration]).to_s
, whichPathname.join
can't handle arraySteps to reproduce the problem
RuboCop version
Reference
Similar to #472 but specific when using %w
The text was updated successfully, but these errors were encountered: