Skip to content

False positive with Rails/FilePath for a list of paths separated by colon including Rails.root #700

Closed
@tk0miya

Description

When I created a list of paths separated by colon (like $PATH envvar) including Rails.root, the Rails/FilePath cop warns to use Rails.root.join. But it's not appropriate in this case.

Expected behavior

No warning is emitted.

Actual behavior

$ bundle exec rubocop --require rubocop-rails
Inspecting 2 files
.C

Offenses:

test.rb:3:8: C: Rails/FilePath: Prefer Rails.root.join('path/to').
PATH = "#{Rails.root}:/path/to/directory"
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

2 files inspected, 1 offense detected

Steps to reproduce the problem

https://github.com/tk0miya/rubocop-rails-bugs is a minimal reproducible project.

RuboCop version

$ bundle exec rubocop --require rubocop-rails -Vbugs [master]
1.28.2 (using Parser 3.1.2.0, rubocop-ast 1.17.0, running on ruby 3.1.2 x86_64-darwin19)
  - rubocop-rails 2.14.2

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions