-
-
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
[Fix #1071] Mark Rails/FilePath
unsafe because of interaction with root filepath
#1400
[Fix #1071] Mark Rails/FilePath
unsafe because of interaction with root filepath
#1400
Conversation
b193fd3
to
c559f7a
Compare
Rails/FilePath
autocorrect for root filepaths by marking cop as unsafe for autocorrectionRails/FilePath
autocorrect for root filepaths by marking cop as unsafe for autocorrection
c559f7a
to
e00b21f
Compare
Rails/FilePath
autocorrect for root filepaths by marking cop as unsafe for autocorrectionRails/FilePath
unsafe for autocorrection because of its effect on root filepath
This came up while I was working on fixing all safely auto-correctable Rubocop rules in our code base. Example problems:
|
@Earlopain Are we doing the right thing here? |
Rails/FilePath
unsafe for autocorrection because of its effect on root filepathRails/FilePath
unsafe because of its effect on root filepath
Rails/FilePath
unsafe because of its effect on root filepathRails/FilePath
unsafe because of its interaction with root filepath
Rails/FilePath
unsafe because of its interaction with root filepathRails/FilePath
unsafe because of interaction with root filepath
…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/>
e00b21f
to
a2e38f9
Compare
Can you add concrete example code in the safety section of the documentation and add a changelog entry? |
@@ -492,6 +492,7 @@ Rails/FilePath: | |||
VersionAdded: '0.47' | |||
VersionChanged: '2.4' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
VersionChanged: '2.4' | |
VersionChanged: '<<next>>' |
This PR will be closed to take the approach of ignoring unsafe cases proposed in #1433. Thank you. |
Here, we add the requested @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
This partly addresses: #1071
See:
And also:
See also:
Rails.root.join '/'
returns#<Pathname:/>
rails/rails#53578This will not be amended in Rails, so the responsibility for the autocorrect behavior falls on Rubocop.
Before submitting the PR make sure the following are checked:
[Fix #issue-number]
(if the related issue exists).master
(if not - rebase it).bundle exec rake default
. It executes all tests and runs RuboCop on its own code.{change_type}_{change_description}.md
if the new code introduces user-observable changes. See changelog entry format for details.