Every file of my rails app i'm editing displays this warning, missing frozen string literal comment
, i know this is used to reserve memory and avoid memory re-allocation for all strings literal, but is it necessary to use on rails or its enabled by default? if so, how to enable it globally?
Nope, it's not enabled by default.
However, you may use Rubocop to append it to the top of your files with Rubocop::Cop::Style::FrozenStringLiteralComment. It's an auto-correctable offense.
According to Holger Just:
You can actually enable it globally by invoking the ruby interpreter with ruby
--enable=frozen-string-literal
. However, this is usually a bad idea and will break in various subtle ways unless you are very sure that all files in all your gems and dependencies actually expect frozen literals (which is generally not the case)