Skip to content

Commit

Permalink
AP-5659: Freeze string literals and use unary + for mutable strings
Browse files Browse the repository at this point in the history
Handle deprecation notices warning of ruby 4.0 intention to default
string literals to be frozen/immutable.

```shell
/Users/joel.sugarman/github/ministryofjustice/laa-apply-for-legal-aid/app/helpers/hash_format_helper.rb:23:
  warning: literal string will be frozen in the future (run with --debug-frozen-string-literal for more information)
```
  • Loading branch information
jsugarman committed Jan 7, 2025
1 parent fd48b9e commit b9d5797
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
6 changes: 4 additions & 2 deletions app/helpers/hash_format_helper.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module HashFormatHelper
# These methods add classes to the HTML structure
def format_hash(hash, html = "")
Expand All @@ -19,7 +21,7 @@ def format_hash(hash, html = "")

def build_dl_array(key, value)
content_tag(:dl, class: "govuk-body kvp govuk-!-margin-bottom-0") do
dl_contents = ""
dl_contents = +""
dl_contents << content_tag(:dt, standardize_key(key))
value.each do |val|
dl_contents << if val.is_a?(Hash)
Expand All @@ -34,7 +36,7 @@ def build_dl_array(key, value)

def build_dl(key, value)
content_tag(:dl, class: "govuk-body kvp govuk-!-margin-bottom-0") do
dl_contents = ""
dl_contents = +""
dl_contents << content_tag(:dt, standardize_key(key))
dl_contents << if standard_type?(value)
content_tag(:dd, value.to_s.capitalize)
Expand Down
4 changes: 3 additions & 1 deletion app/helpers/language_switcher_helper.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# frozen_string_literal: true

module LanguageSwitcherHelper
def language_links
links = ""
links = +""

I18n.available_locales.each do |locale|
link = I18n.locale == locale ? t("generic.#{locale}") : govuk_link_to(t("generic.#{locale}"), url_for(locale:))
Expand Down
2 changes: 1 addition & 1 deletion features/support/steps_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
end

Then("I choose the {string} frequency for {string}") do |frequency, field|
parts = [field, "frequency", frequency]
parts = [field, +"frequency", frequency]
parts.each(&:downcase!)
field_id = parts.join(" ").gsub(/\s+/, "-")
id = find("input[id*=#{field_id}", visible: false)[:id]
Expand Down

0 comments on commit b9d5797

Please sign in to comment.