From 0fbc0759539c1ba8f864e9fa65cee37255c6d36a Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Thu, 19 Mar 2026 23:02:29 +0000 Subject: [PATCH] Enforce declaration of local variables for partials --- .herb.yml | 2 ++ app/helpers/application_helper.rb | 2 +- app/views/accounts/_go_public.html.erb | 2 ++ app/views/accounts/terms/_terms.html.erb | 2 ++ app/views/accounts/terms/_terms_declined_flash.html.erb | 2 ++ app/views/api/notes/_comment.html.erb | 2 ++ app/views/api/notes/_description.html.erb | 2 ++ app/views/api/notes/_entry.html.erb | 2 ++ app/views/application/_auth_button.html.erb | 1 + app/views/application/_auth_providers.html.erb | 2 ++ app/views/application/_settings_menu.html.erb | 2 ++ app/views/application/_sidebar_header.html.erb | 2 ++ app/views/browse/_common_details.html.erb | 2 ++ app/views/browse/_containing_relation.html.erb | 2 ++ app/views/browse/_node.html.erb | 2 ++ app/views/browse/_relation.html.erb | 2 ++ app/views/browse/_relation_member.html.erb | 2 ++ app/views/browse/_relation_member_frame.html.erb | 2 ++ app/views/browse/_tag.html.erb | 2 ++ app/views/browse/_tag_details.html.erb | 2 ++ app/views/browse/_way.html.erb | 2 ++ app/views/changeset_comments/feeds/_comment.html.erb | 2 ++ app/views/changeset_subscriptions/_heading.html.erb | 2 ++ app/views/changesets/_changeset.html.erb | 2 ++ app/views/changesets/_changeset_line.html.erb | 1 + app/views/changesets/_elements.html.erb | 2 ++ app/views/changesets/_not_found_message.html.erb | 2 ++ app/views/changesets/_paging_nav.html.erb | 2 ++ app/views/confirmations/_resend_success_flash.html.erb | 2 ++ app/views/dashboards/_contact.html.erb | 2 ++ app/views/dashboards/_popup.html.erb | 2 ++ app/views/diary_entries/_diary_comment.html.erb | 2 ++ app/views/diary_entries/_diary_entry.html.erb | 2 ++ app/views/diary_entries/_diary_entry_heading.html.erb | 2 ++ app/views/diary_entries/_form.html.erb | 2 ++ app/views/diary_entries/_location.html.erb | 2 ++ app/views/diary_entries/_navigation.html.erb | 2 ++ app/views/diary_entries/_page.html.erb | 2 ++ app/views/diary_entries/_profile_diaries.html.erb | 2 ++ app/views/errors/_contact.html.erb | 2 ++ app/views/issues/_comments.html.erb | 2 ++ app/views/issues/_page.html.erb | 2 ++ app/views/issues/_reports.html.erb | 2 ++ app/views/issues/reporters/_reporters.html.erb | 2 ++ app/views/languages_panes/_select_language_list.html.erb | 2 ++ app/views/layouts/_banner.html.erb | 2 ++ app/views/layouts/_content.html.erb | 4 +++- app/views/layouts/_flash.html.erb | 2 ++ app/views/layouts/_head.html.erb | 2 ++ app/views/layouts/_header.html.erb | 2 ++ app/views/layouts/_markers.html.erb | 2 ++ app/views/layouts/_meta.html.erb | 2 ++ app/views/layouts/_search.html.erb | 2 ++ app/views/layouts/_select_language_button.html.erb | 2 ++ app/views/layouts/_sidebar_close.html.erb | 2 ++ app/views/messages/mailboxes/_heading.html.erb | 2 ++ app/views/messages/mailboxes/_message.html.erb | 2 ++ app/views/messages/mailboxes/_messages_table.html.erb | 2 ++ app/views/messages/outboxes/_message.html.erb | 2 ++ app/views/nodes/_not_found_message.html.erb | 2 ++ app/views/notes/_not_found_message.html.erb | 2 ++ app/views/notes/_notes_paging_nav.html.erb | 2 ++ app/views/oauth2_applications/_application.html.erb | 2 ++ app/views/oauth2_applications/_form.html.erb | 2 ++ .../oauth2_authorized_applications/_application.html.erb | 2 ++ app/views/old_elements/_actions.html.erb | 2 ++ app/views/old_nodes/_not_found_message.html.erb | 2 ++ app/views/old_relation_members/_not_found_message.html.erb | 2 ++ app/views/old_relations/_not_found_message.html.erb | 2 ++ app/views/old_ways/_not_found_message.html.erb | 2 ++ app/views/preferences/preferences/_navigation.html.erb | 2 ++ .../preferences/preferences/_update_success_flash.html.erb | 2 ++ app/views/profiles/profile_sections/_navigation.html.erb | 2 ++ app/views/redactions/_redaction.html.erb | 2 ++ app/views/relation_members/_not_found_message.html.erb | 2 ++ app/views/relations/_not_found_message.html.erb | 2 ++ app/views/sessions/_suspended_flash.html.erb | 2 ++ app/views/shared/_markdown_help.html.erb | 2 ++ app/views/shared/_pagination.html.erb | 2 ++ app/views/shared/_richtext_field.html.erb | 2 ++ app/views/shared/_section_divider.html.erb | 2 ++ app/views/site/_about_section.html.erb | 4 +++- app/views/site/_add_a_note.html.erb | 2 ++ app/views/site/_any_questions.html.erb | 2 ++ app/views/site/_id.html.erb | 2 ++ app/views/site/_potlatch.html.erb | 2 ++ app/views/site/_potlatch2.html.erb | 2 ++ app/views/social_links/_show.html.erb | 2 ++ app/views/traces/_page.html.erb | 2 ++ app/views/traces/_trace.html.erb | 2 ++ app/views/traces/feeds/_description.html.erb | 2 ++ app/views/user_blocks/_block.html.erb | 2 ++ app/views/user_blocks/_navigation.html.erb | 2 ++ app/views/user_blocks/_page.html.erb | 2 ++ app/views/user_mailer/_gpx_details.html.erb | 2 ++ app/views/user_mailer/_message_body.html.erb | 2 ++ app/views/users/_auth_association.html.erb | 2 ++ app/views/users/_role_icons.html.erb | 2 ++ app/views/users/_sidebar_section.html.erb | 3 ++- app/views/users/changeset_comments/_page.html.erb | 2 ++ app/views/users/diary_comments/_page.html.erb | 2 ++ app/views/users/lists/_page.html.erb | 2 ++ app/views/users/lists/_user.html.erb | 2 ++ app/views/ways/_not_found_message.html.erb | 2 ++ 104 files changed, 207 insertions(+), 4 deletions(-) diff --git a/.herb.yml b/.herb.yml index de8fa288e..acb0d8578 100644 --- a/.herb.yml +++ b/.herb.yml @@ -4,6 +4,8 @@ linter: rules: erb-no-instance-variables-in-partials: enabled: false + erb-strict-locals-required: + enabled: true html-anchor-require-href: enabled: false html-no-space-in-tag: diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index c42a2a252..a084cd3cd 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -85,7 +85,7 @@ module ApplicationHelper # This allows us to render html into a flash message in a safe manner. def render_flash(flash) if flash.is_a?(Hash) - render flash.with_indifferent_access + render flash.deep_symbolize_keys else flash end diff --git a/app/views/accounts/_go_public.html.erb b/app/views/accounts/_go_public.html.erb index 51bb85234..2ad3f2de0 100644 --- a/app/views/accounts/_go_public.html.erb +++ b/app/views/accounts/_go_public.html.erb @@ -1,3 +1,5 @@ +<%# locals: () %> +

<%= t ".heading" %>

diff --git a/app/views/accounts/terms/_terms.html.erb b/app/views/accounts/terms/_terms.html.erb index 20c6a7a8e..f684343e6 100644 --- a/app/views/accounts/terms/_terms.html.erb +++ b/app/views/accounts/terms/_terms.html.erb @@ -1,3 +1,5 @@ +<%# locals: () %> +

<%= @text["intro"] %> <%= @text["next_with_decline"] %> diff --git a/app/views/accounts/terms/_terms_declined_flash.html.erb b/app/views/accounts/terms/_terms_declined_flash.html.erb index 9c9d793db..c107ec8dc 100644 --- a/app/views/accounts/terms/_terms_declined_flash.html.erb +++ b/app/views/accounts/terms/_terms_declined_flash.html.erb @@ -1 +1,3 @@ +<%# locals: () %> + <%= t ".terms_declined_html", :terms_declined_link => link_to(t(".terms_declined_link"), t(".terms_declined_url")) %> diff --git a/app/views/api/notes/_comment.html.erb b/app/views/api/notes/_comment.html.erb index 437bd68a4..f318775af 100644 --- a/app/views/api/notes/_comment.html.erb +++ b/app/views/api/notes/_comment.html.erb @@ -1,3 +1,5 @@ +<%# locals: (comment:) %> +

<% if comment.author.nil? -%> diff --git a/app/views/api/notes/_description.html.erb b/app/views/api/notes/_description.html.erb index 4f03a1d59..02dc99555 100644 --- a/app/views/api/notes/_description.html.erb +++ b/app/views/api/notes/_description.html.erb @@ -1,3 +1,5 @@ +<%# locals: (description:) %> +
<%= render :partial => "comment", :collection => description.comments %>
diff --git a/app/views/api/notes/_entry.html.erb b/app/views/api/notes/_entry.html.erb index 624ecd15d..db3ce6b6f 100644 --- a/app/views/api/notes/_entry.html.erb +++ b/app/views/api/notes/_entry.html.erb @@ -1,3 +1,5 @@ +<%# locals: (entry:) %> +

<%= t ".comment" %>

<%= render :partial => "comment", :object => entry %>

<%= t ".full" %>

diff --git a/app/views/application/_auth_button.html.erb b/app/views/application/_auth_button.html.erb index 341c8a12f..429e36a8b 100644 --- a/app/views/application/_auth_button.html.erb +++ b/app/views/application/_auth_button.html.erb @@ -1,4 +1,5 @@ <%# locals: (provider:, preferred: false) %> + <%= link_to auth_path(:provider => provider), :method => :post, :class => ["auth_button btn btn-outline-secondary border p-2", { "px-4 d-flex gap-3 justify-content-center align-items-center" => preferred }], diff --git a/app/views/application/_auth_providers.html.erb b/app/views/application/_auth_providers.html.erb index 7a8f5835c..c8ee1a59f 100644 --- a/app/views/application/_auth_providers.html.erb +++ b/app/views/application/_auth_providers.html.erb @@ -1,3 +1,5 @@ +<%# locals: () %> + <% prefered_auth_button_available = Auth.providers.include?(@preferred_auth_provider) %>
diff --git a/app/views/application/_settings_menu.html.erb b/app/views/application/_settings_menu.html.erb index a0d3c0ad4..c8d758e11 100644 --- a/app/views/application/_settings_menu.html.erb +++ b/app/views/application/_settings_menu.html.erb @@ -1,3 +1,5 @@ +<%# locals: () %> + <% content_for :heading_class, "pb-0" %> <% content_for :heading do %> diff --git a/app/views/application/_sidebar_header.html.erb b/app/views/application/_sidebar_header.html.erb index d24a0c5fa..585505c4f 100644 --- a/app/views/application/_sidebar_header.html.erb +++ b/app/views/application/_sidebar_header.html.erb @@ -1 +1,3 @@ +<%# locals: (title:) %> +

<%= title %>

diff --git a/app/views/browse/_common_details.html.erb b/app/views/browse/_common_details.html.erb index 92a88a6bc..4ef44cdbd 100644 --- a/app/views/browse/_common_details.html.erb +++ b/app/views/browse/_common_details.html.erb @@ -1,3 +1,5 @@ +<%# locals: (common_details:) %> +

<%= if common_details.redacted? t "browse.redacted_version" diff --git a/app/views/browse/_containing_relation.html.erb b/app/views/browse/_containing_relation.html.erb index 2c1072364..0b5cc21b1 100644 --- a/app/views/browse/_containing_relation.html.erb +++ b/app/views/browse/_containing_relation.html.erb @@ -1,3 +1,5 @@ +<%# locals: (containing_relation:) %> + <%= element_list_item "relation", containing_relation.relation do %> <%= linked_name = link_to printable_element_name(containing_relation.relation), containing_relation.relation if containing_relation.member_role.blank? diff --git a/app/views/browse/_node.html.erb b/app/views/browse/_node.html.erb index cc3804da5..78dc8a9e7 100644 --- a/app/views/browse/_node.html.erb +++ b/app/views/browse/_node.html.erb @@ -1,3 +1,5 @@ +<%# locals: (node:) %> + <%= tag.div :class => ["mb-3 border-bottom border-secondary-subtle pb-3", { "text-body-secondary" => node.redacted? && params[:show_redactions] }] do %> <% if node.redacted? && !params[:show_redactions] %> diff --git a/app/views/browse/_relation.html.erb b/app/views/browse/_relation.html.erb index b09316fd2..7736b19cf 100644 --- a/app/views/browse/_relation.html.erb +++ b/app/views/browse/_relation.html.erb @@ -1,3 +1,5 @@ +<%# locals: (relation:) %> + <%= tag.div :class => ["mb-3 border-bottom border-secondary-subtle pb-3", { "text-body-secondary" => relation.redacted? && params[:show_redactions] }] do %> <% if relation.redacted? && !params[:show_redactions] %> diff --git a/app/views/browse/_relation_member.html.erb b/app/views/browse/_relation_member.html.erb index 66402b18d..48ad59beb 100644 --- a/app/views/browse/_relation_member.html.erb +++ b/app/views/browse/_relation_member.html.erb @@ -1,3 +1,5 @@ +<%# locals: (relation_member:) %> + <%= element_list_item_with_strikethrough relation_member.member_type.downcase, relation_member.member do %> <%= t ".entry_#{'role_' if relation_member.member_role.present?}html", :type => t(".type.#{relation_member.member_type.downcase}"), diff --git a/app/views/browse/_relation_member_frame.html.erb b/app/views/browse/_relation_member_frame.html.erb index 97531f17a..eab69c974 100644 --- a/app/views/browse/_relation_member_frame.html.erb +++ b/app/views/browse/_relation_member_frame.html.erb @@ -1,3 +1,5 @@ +<%# locals: (relation:, frame_id:) %> +