Repository navigation
Add frozen_string_literal: true to all Ruby files - #21
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 re-lands #19 on
master. #19 was stacked on the "Remove redundant coding comments" PR (#18), and after #18 merged, #19 merged into #18's branch instead ofmaster, somasternever got these changes. This PR contains the same change, rebased onto the currentmaster.Why
Ruby 4.0 warns when code mutates a string literal ("chilled strings"), and a future Ruby version is expected to freeze string literals by default. Files with
# frozen_string_literal: truealready behave that way today, so adding the comment makes the gem's behaviour the same now and after that change.What changed
# frozen_string_literal: true, followed by a blank line, to all Ruby files (lib, specs, gemspec,Gemfile,Rakefile,script/turbux_rspec).Style/FrozenStringLiteralCommentandLayout/EmptyLineAfterMagicCommentin.rubocop.yml, so new files keep the comment.No code changes were needed:
<<calls append to arrays (tokens, entries, the parse stack), not strings.Sie::Document::Rendererbuilds its output with interpolation,+,gsubandencode, which all return new strings, and writes into its ownStringIO.newbuffer, which isn't frozen.How it was verified
bundle exec rake: 34 + 4 examples, 0 failures.RUBYOPT=--enable-frozen-string-literal), which freezes every literal in the gem and its specs: 34 + 4 examples, 0 failures.RUBYOPT=-W:deprecated: no chilled-string warnings.Risk
Low: the diff only adds magic comments and RuboCop config.