Add # frozen_string_literal: true
#172
Open
+72
−5
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This addresses two issues::
In Ruby 3.5 and later, string literals are frozen by default. As a result, even if there’s no actual runtime issue, deprecation warnings may appear on Ruby 3.4. For example, running tests on Ruby 3.4 with
RUBYOPT=-W:deprecated
will display these warnings.To address this warning, it’s recommended to consistently add
# frozen_string_literal: true
at the top of files. In this case, I applied it to all affected files. The process was automated using the command:The
Rack::Tracker::GoogleTagManager#inject
method provided by this library is implemented on the assumption that it receives a mutable string as an argument; specifically, it internally callsString#sub!
on that string. While this is generally fine as long as users pass in a mutable string, the library’s test code originally passed string literals to test this behavior. Therefore, some care was needed when making changes in this context.Additionally,
String#force_encoding
was used to create strings with a specific encoding, so special care was also needed for this part during the current changes.