-
Notifications
You must be signed in to change notification settings - Fork 147
Add frozen_string_literal: false to files that modify strings and run tests with frozen strings
#640
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
Conversation
|
I gave this a try and now I am not getting |
|
@Temikus Is this something you could take a look at? |
| test: | ||
| runs-on: fog-arc-runner | ||
| env: | ||
| RUBYOPT: "--enable-frozen-string-literal" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't we expect these tests to fail without fixes for the frozen strings?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To those files that modify strings I added:
# frozen_string_literal: false
That overrides the RUBYOPT for those files. The final behaviour should be that by default for all files the strings are frozen and for those few files the string literals are not frozen.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, right, that's unexpected, though; usually I see # frozen_string_literal: true, or it's omitted entirely because false is the default.
I'm not opposed to this approach as a step 1. However, at the moment these integration tests need to be run by hand. I suspect just fixing the frozen string issue is relatively straightforward that we might as well try to fix them on a file-by-file basis, such as:
diff --git a/lib/fog/google/storage/storage_json/real.rb b/lib/fog/google/storage/storage_json/real.rb
index 23c86c5..ab99372 100644
--- a/lib/fog/google/storage/storage_json/real.rb
+++ b/lib/fog/google/storage/storage_json/real.rb
@@ -45,7 +45,7 @@ DATA
end
string_to_sign << canonical_google_headers.to_s
- canonical_resource = "/"
+ canonical_resource = +"/"
if subdomain = params.delete(:subdomain)
canonical_resource << "#{CGI.escape(subdomain).downcase}/"
end
diff --git a/lib/fog/google/storage/storage_xml/real.rb b/lib/fog/google/storage/storage_xml/real.rb
index 166e181..5c15bfc 100644
--- a/lib/fog/google/storage/storage_xml/real.rb
+++ b/lib/fog/google/storage/storage_xml/real.rb
@@ -57,7 +57,7 @@ DATA
end
string_to_sign << canonical_google_headers.to_s
- canonical_resource = "/"
+ canonical_resource = +"/"
if subdomain = params.delete(:subdomain)
canonical_resource << "#{CGI.escape(subdomain).downcase}/"
endThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd be happy if these changes could be applied directly, I just don't know the codebase so well and I saw there were a fair amount of modifications, so I went for the easy fix. That can still be applied after this PR.
Oh, right, that's unexpected, though; usually I see # frozen_string_literal: true, or it's omitted entirely because false is the default.
Yeah, but that default will eventually change. If someone tries to already enable --enable-frozen-string-literal (as I did), they will get errors. This PR at least fixes that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FWIW, using +"..." was how we solved this for excon and it worked well (though it is a bit annoying initially).
|
Let's close this in favor of #646. |
Partially addresses #639. It runs tests with frozen strings, but allows modifying strings for those files with
frozen_string_literal: false. This should allow usingfog-googlein projects that useRUBYOPT="--enable-frozen-string-literal"without errors. Next step would involve removing the strings modifications. This is more involved, so I thought that it would make sense to do this first.