Rubocop: False positive in Rails/FilePath

Created on 28 Feb 2018  Â·  3Comments  Â·  Source: rubocop-hq/rubocop

On master branch (6c3ea4753bbb9f1ffb0f2ee60400fd0b432ede3f) I’m seeing Rails/FilePath complain about this code:

<<-FOO
  1
  /
FOO
test.rb:1:1: C: Rails/FilePath: Please use Rails.root.join('path', 'to') instead.
<<-FOO
^^^^^^

With git bisect I found that the false positive was introduced in 707c9a85c1d99bfee8a10ac404abf6a14d6a88f0 – cc @koic


Expected behavior

No offense should be found.

Actual behavior

An offense found for Rails/FilePath.

Steps to reproduce the problem

See above.

RuboCop version

$ rubocop -V
0.52.1 (using Parser 2.5.0.2, running on ruby 2.4.2 x86_64-darwin15)
$ git rev-parse @
6c3ea4753bbb9f1ffb0f2ee60400fd0b432ede3f

All 3 comments

Thanks for the feedback.
I reproduced this false positive. I will investigate.

I just found another false positive which may be related.

'' \
'/'
test.rb:1:1: C: Rails/FilePath: Please use Rails.root.join('path', 'to') instead.
'' \
^^^

One more:

"#{42}/"
test.rb:1:1: C: Rails/FilePath: Please use Rails.root.join('path', 'to') instead.
"#{42}/"
^^^^^^^^
Was this page helpful?
0 / 5 - 0 ratings

Related issues

millisami picture millisami  Â·  3Comments

deivid-rodriguez picture deivid-rodriguez  Â·  3Comments

herwinw picture herwinw  Â·  3Comments

Aqualon picture Aqualon  Â·  3Comments

mikegee picture mikegee  Â·  3Comments