You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using Ruby version 3.4.1 and add Warning[:deprecated] = true to spec_helper.rb results in numerous deprecation warnings due to the mutation of literal strings.
One example:
/Users/nick/projects/phony/lib/phony/country_codes.rb:158: warning: literal string will be frozen in the future (run with --debug-frozen-string-literal for more information)
Looking at the majority of warnings they are due to the use of String#slice!.
I started to work on a patch to fix the warnings however in some cases it seems as though the gem is relying on the mutation of arguments. I've attached a patch for one example in the 'trunk_code.rb'. Updating split to not mutate national_number causes qed test failures.
From 5ddb8251fcf7b910850a3c7ce3fd9641f280e2b0 Mon Sep 17 00:00:00 2001
From: Nick Maher <[email protected]>
Date: Mon, 30 Dec 2024 10:07:08 +0000
Subject: [PATCH] Trunk code example
---
lib/phony/trunk_code.rb | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/lib/phony/trunk_code.rb b/lib/phony/trunk_code.rb
index c1dfae7..cd14eb7 100644
--- a/lib/phony/trunk_code.rb+++ b/lib/phony/trunk_code.rb@@ -29,8 +29,10 @@ module Phony
# its parts.
#
def split(national_number)
- national_number.gsub! @trunk_code_replacement, EMPTY_STRING if @split- [self, national_number]+ return [self, national_number] unless @split++ without_trunk = national_number.gsub @trunk_code_replacement, EMPTY_STRING+ [self, without_trunk]
end
# Normalize normalizes the given national number.
--
2.42.1
The text was updated successfully, but these errors were encountered:
Using Ruby version 3.4.1 and add
Warning[:deprecated] = true
tospec_helper.rb
results in numerous deprecation warnings due to the mutation of literal strings.One example:
Looking at the majority of warnings they are due to the use of
String#slice!
.I started to work on a patch to fix the warnings however in some cases it seems as though the gem is relying on the mutation of arguments. I've attached a patch for one example in the 'trunk_code.rb'. Updating
split
to not mutatenational_number
causes qed test failures.The text was updated successfully, but these errors were encountered: