-
-
Notifications
You must be signed in to change notification settings - Fork 268
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rails/FilePath autocorrect shouldn't remove important trailing slash in dynamic string containing Rails.root #1177
Comments
corsonknowles
added a commit
to corsonknowles/rubocop-rails
that referenced
this issue
Dec 23, 2024
…filepaths by marking cop as unsafe for autocorrection We correctly add a @safety annotation for Rails/FilePath since it can produce invalid code like this: # pass any string argument beginning with '/' to Rails.root.join and it will omit the Rails path (dev)> Rails.root.join '/' => #<Pathname:/> (dev)> Rails.root.join '//' => #<Pathname://> (dev)> Rails.root.join '/abc' => #<Pathname:/abc> (dev)> Rails.root.join '/abc/' => #<Pathname:/abc/>
9 tasks
ydakuka
added a commit
to ydakuka/rubocop-rails
that referenced
this issue
Feb 8, 2025
…mportant trailing slash in a dynamic string containing `Rails.root`
ydakuka
added a commit
to ydakuka/rubocop-rails
that referenced
this issue
Feb 9, 2025
…mportant trailing slash in a dynamic string containing `Rails.root`
ydakuka
added a commit
to ydakuka/rubocop-rails
that referenced
this issue
Feb 9, 2025
…mportant trailing slash in a dynamic string containing `Rails.root`
ydakuka
added a commit
to ydakuka/rubocop-rails
that referenced
this issue
Feb 9, 2025
…mportant trailing slash in a dynamic string containing `Rails.root`
7 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm trying to use Rails.root to remove it from an absolute filepath to result in a filepath relative to Rails.root.
Expected behavior
Actual behavior
Steps to reproduce the problem
Copy the below into a file, run RuboCop with autocorrect enabled and manually fix any other cops that are raised, then assert that the result is true.
rubocop-rails-filepath-test.rb
RuboCop version
The text was updated successfully, but these errors were encountered: