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

Avoid mutating string literals #1339

Merged
merged 6 commits into from
Sep 1, 2021
Merged

Avoid mutating string literals #1339

merged 6 commits into from
Sep 1, 2021

Conversation

tommy-gilligan
Copy link
Contributor

@tommy-gilligan tommy-gilligan commented May 4, 2021

  • Makes the tests a bit more accurate in replicating what output_buffer looks like in a Rails app.
  • Adds # frozen_string_literal: true to all *.rb files
  • Replaced string literal mutation in as many places as possible

@tommy-gilligan
Copy link
Contributor Author

Needs #1340 for green build

Copy link
Contributor

@mikz mikz left a comment

Choose a reason for hiding this comment

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

I think this looks good.

I'm a tiny bit worried that this might affect some user code. Like custom inputs & actions. If someone inherits & extends those they would need to stop mutating strings too.

Have you had any issues with this in activeadmin?

These helpers use rails methods to generate html, which is not frozen
string. It should always return the same kind of string, so it shall
return non frozen string.
@mikz
Copy link
Contributor

mikz commented Aug 31, 2021

@tomgilligan hey, I pushed to your PR.

Reverted the change of string concatenation instead of mutation. Rails methods like content_tag return mutable strings, so all code paths can rely on them. We should just keep doing the same thing in all code paths.
It could be a massive change for user code that actually relies on these mutable strings.

@mikz mikz merged commit e34baba into formtastic:master Sep 1, 2021
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.

None yet

2 participants