daddyz / phonelib

Ruby gem for phone validation and formatting using google libphonenumber library data
MIT License
1.08k stars 132 forks source link

Add compatibility with --enable-frozen-string-literal #305

Closed jonleighton closed 1 week ago

jonleighton commented 6 months ago

Since Ruby 2.7, Ruby can be run with --enable-frozen-string-literal to improve memory efficiency and avoid mistakes.

Ruby 3.4 is also now moving towards a world where string literals are frozen by default: https://www.ruby-lang.org/en/news/2024/05/16/ruby-3-4-0-preview1-released/

This commit handles errors that arise when Phonelib is run with this feature enabled. It add the option to the CI configuration via an environment variable to ensure that regressions are not introduced.

In doing so, I needed to upgrade the simplecov gem to at least 0.15.0, because that’s the first version that is compatible with --enable-frozen-string-literal: https://github.com/simplecov-ruby/simplecov/blob/main/CHANGELOG.old.md#0150-2017-08-14-changes

This upgrade was prevented by the codeclimate-test-reporter gem, which locks simplecov to <= 0.13.

However, I found that codeclimate-test-reporter is deprecated (https://github.com/codeclimate/ruby-test-reporter) and also that the uses of it in this codebase had already been commented out. Therefore I have removed it entirely, enabling the upgrade to simplecov.

radville commented 3 months ago

👋 Hi @jonleighton! We were hoping to see this work as well! Are you still hoping to push this forward?

@daddyz what do you think of these changes? Anything we can do to help add this functionality? 😄

jonleighton commented 3 months ago

Yes, I'd still be keen to get this merged.