Prepare AP and AR to be frozen string friendly#29655
Prepare AP and AR to be frozen string friendly#29655matthewd merged 1 commit intorails:masterfrom kirs:frozen-friendly-ap-ar
Conversation
|
r? @eileencodes (@rails-bot has picked a reviewer for you, use r? to override) |
|
Ah, must be things that aren't covered by tests? That's how I was checking things - running the tests with |
|
Fixed a failing test. @pat those can be reproduced in master with: upd: |
There was a problem hiding this comment.
Mismerge with b86e313? This doesn't seem to be needed.
|
These |
|
@kamipo I think that happens because Our goal is to enforce it in Rails codebase (#29540) so I think we should rely on |
There was a problem hiding this comment.
Is this dup necessary? Looks like that strip_heredoc returns new string and we have no strip_heredoc.dup.
https://github.com/rails/rails/blob/v5.1.2/activesupport/lib/active_support/core_ext/string/strip.rb#L21
% git grep 'strip_heredoc\.dup' | wc -l
0
|
@kamipo you were right, that one wasn't necessary. Thanks for 👀 it! I updated the code. |
|
Could you add the magic comments to the changed files? |
There was a problem hiding this comment.
I'm torn on this one.. does the change belong here, or is it the caller's responsibility to provide an unfrozen value?
actionpack/test/abstract_unit.rb
Outdated
There was a problem hiding this comment.
What about using sub instead of sub!, maybe that works better here?
|
Thanks for feedback! I addressed those. If you think it's a good idea, I can also add these lines to Style/FrozenStringLiteralComment:
Enabled: true
EnforcedStyle: always
Include:
- 'actionpack/**/*'
- 'activerecord/**/*'However that would made the PR diff quite big to 👀 . My initial plan was to do it in a separate PR. |
|
Yeah, separate PR. |
There was a problem hiding this comment.
I think we can remove all those freeze here
There was a problem hiding this comment.
Good idea! I didn't want to do that at first, but now when we have # frozen_string_literal: true in the updated files it makes sense to do it.
I updated the PR.
|
@matthewd please let me know if there's anything else I can improve in this PR. |
This PR makes ActionPack and ActiveRecord frozen string -friendly.
Shipping it should unblock us to move towards enforcing frozen-string-literal across all Rails components.
@matthewd
ref #29540
ref #29506