Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use frozen_string_literal in class Command #2

Merged
merged 1 commit into from
May 17, 2024

Conversation

allan-pires
Copy link

@allan-pires allan-pires commented May 15, 2024

Description

Adds frozen_string_literal: true magic comment to enable frozen string literals on Progeny::Command.
Also uses +'' to create mutable strings for @out and @err.

Context

There was a deprecation warning for chilled strings merged recently in Ruby: ruby/ruby@12be40a

And with that we started to see the following warnings on progeny:

 /vendor/gems/3.4.0/ruby/3.4.0+0/gems/progeny-0.2.0/lib/progeny/command.rb:238:in 'String#force_encoding':
 /vendor/gems/3.4.0/ruby/3.4.0+0/gems/progeny-0.2.0/lib/progeny/command.rb:239:in 'String#force_encoding':

@luanzeba luanzeba self-requested a review May 16, 2024 03:04
@@ -228,7 +229,7 @@ def exec!
# exceeds the amount specified by the max argument.
def read_and_write(input, stdin, stdout, stderr, timeout=nil, max=nil)
max = nil if max && max <= 0
@out, @err = '', ''
@out, @err = +'', +''
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+@: Returns a string that is not frozen: self, if not frozen; self.dup otherwise.

https://ruby-doc.org/3.2.2/String.html#class-String-label-Methods+for+a+Frozen-2FUnfrozen+String

Copy link
Owner

@luanzeba luanzeba left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! ✨

@luanzeba luanzeba merged commit 22be5fe into luanzeba:main May 17, 2024
1 check passed
@allan-pires allan-pires deleted the frozen-strings branch June 5, 2024 16:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants