Skip to content

Commit

Permalink
Address warning: literal string will be frozen in the future
Browse files Browse the repository at this point in the history
This commit addresses the following warnings.

- Steps to reproduce:
```ruby
$ ruby -v
ruby 3.4.0dev (2024-10-26T13:20:34Z master 484ea00d2e) +PRISM [x86_64-linux]
$ RUBYOPT="--debug-frozen-string-literal" bundle exec thor spec
```

- Warnings addressed by this commit:
```
/path/to/thor/spec/base_spec.rb:322: warning: literal string will be frozen in the future
/path/to/thor/spec/base_spec.rb:321: info: the string was created here
```

```
/path/to/thor/spec/parser/options_spec.rb:121: warning: literal string will be frozen in the future
/path/to/thor/spec/parser/options_spec.rb:120: info: the string was created here
```

Refer to:
https://bugs.ruby-lang.org/issues/20205
ruby/ruby#11893
  • Loading branch information
yahonda committed Oct 30, 2024
1 parent b19962a commit 549fbcf
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion spec/base_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ def hello
end

it "suggests commands that are similar if there is a typo" do
expected = "Could not find command \"paintz\" in \"barn\" namespace.\n"
expected = "Could not find command \"paintz\" in \"barn\" namespace.\n".dup
expected << "Did you mean? \"paint\"\n" if Thor::Correctable

expect(capture(:stderr) { Barn.start(%w(paintz)) }).to eq(expected)
Expand Down
2 changes: 1 addition & 1 deletion spec/parser/options_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def remaining
create foo: "baz", bar: :required
parse("--bar", "baz", "--baz", "unknown")

expected = "Unknown switches \"--baz\""
expected = "Unknown switches \"--baz\"".dup
expected << "\nDid you mean? \"--bar\"" if Thor::Correctable

expect { check_unknown! }.to raise_error(Thor::UnknownArgumentError) do |error|
Expand Down

0 comments on commit 549fbcf

Please sign in to comment.