Skip to content

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

Closed
@tk0miya

Description

@tk0miya
Contributor

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

added a commit that references this issue on May 2, 2022

[Fix rubocop#700] Fix a false positive for `Rails/FilePath`

85a0c2d
added a commit that references this issue on May 2, 2022

[Fix rubocop#700] Fix a false positive for `Rails/FilePath`

4977ea3
added a commit that references this issue on May 2, 2022

Merge pull request #701 from tk0miya/fix_a_false_positive_for_rails_f…

e4b9942
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

        Participants

        @tk0miya

        Issue actions

          False positive with Rails/FilePath for a list of paths separated by colon including Rails.root · Issue #700 · rubocop/rubocop-rails