[20220613 update] better use robocop auto-correct to handle this issue.
[20220728 update] bundle exec rubocop -A **/*.rb --only Style/FrozenStringLiteralComment
I’ve read a blog post written by Mike Perham introducing the Magic Comment, and I tried it out in my project.
The # frozen_string_literal: true
STEP-1: add this “magic comment”
1 | # Find all ruby files. |
STEP-2: do automated/manual tests
This is important, since your project code may have a situation for manipulating Mutable String.
STEP-3: deploy and pay extra attention to production state
Be ready to rollback your deployment. You know, shit happens.
Exception occurred: FrozenError
Yes, it happened…
1 | { |
Occurrence No.1
1 | # frozen_string_literal: true |
solution
1 | # frozen_string_literal: true |
Occurrence No.2
1 | # frozen_string_literal: true |
solution
1 | # frozen_string_literal: true |
At Last
But to my disappointment, I didn’t see significant memory reduction.
It might be related to the size of the system.(Is it?)