From 39b60219fe37d1e3f94555a053895adc1eee179c Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Thu, 11 Jun 2020 19:19:12 +0100 Subject: [PATCH 1/1] Fix new rubocop warnings --- app/helpers/application_helper.rb | 14 +++++++------- app/helpers/browse_helper.rb | 6 +++--- app/helpers/browse_tags_helper.rb | 2 +- app/helpers/issues_helper.rb | 4 ++-- app/helpers/notifier_helper.rb | 3 +-- app/helpers/user_roles_helper.rb | 2 +- app/models/issue.rb | 2 +- app/models/note_comment.rb | 4 ++-- app/models/relation_member.rb | 2 +- app/models/user_block.rb | 6 +++--- 10 files changed, 22 insertions(+), 23 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 79c6e6134..5f36e262b 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -21,15 +21,15 @@ module ApplicationHelper id = "#{object_name}_#{method}" type = options.delete(:format) || "markdown" - content_tag(:div, :id => "#{id}_container", :class => "richtext_container") do - output_buffer << content_tag(:div, :id => "#{id}_content", :class => "richtext_content") do + tag.div(:id => "#{id}_container", :class => "richtext_container") do + output_buffer << tag.div(:id => "#{id}_content", :class => "richtext_content") do output_buffer << text_area(object_name, method, options.merge("data-preview-url" => preview_url(:type => type))) - output_buffer << content_tag(:div, "", :id => "#{id}_preview", :class => "richtext_preview richtext") + output_buffer << tag.div("", :id => "#{id}_preview", :class => "richtext_preview richtext") end - output_buffer << content_tag(:div, :id => "#{id}_help", :class => "richtext_help") do + output_buffer << tag.div(:id => "#{id}_help", :class => "richtext_help") do output_buffer << render("site/#{type}_help") - output_buffer << content_tag(:div, :class => "buttons") do + output_buffer << tag.div(:class => "buttons") do output_buffer << submit_tag(I18n.t("site.richtext_area.edit"), :id => "#{id}_doedit", :class => "richtext_doedit deemphasize", :disabled => true) output_buffer << submit_tag(I18n.t("site.richtext_area.preview"), :id => "#{id}_dopreview", :class => "richtext_dopreview deemphasize") end @@ -46,11 +46,11 @@ module ApplicationHelper end def friendly_date(date) - content_tag(:span, time_ago_in_words(date), :title => l(date, :format => :friendly)) + tag.span(time_ago_in_words(date), :title => l(date, :format => :friendly)) end def friendly_date_ago(date) - content_tag(:span, time_ago_in_words(date, :scope => :'datetime.distance_in_words_ago'), :title => l(date, :format => :friendly)) + tag.span(time_ago_in_words(date, :scope => :'datetime.distance_in_words_ago'), :title => l(date, :format => :friendly)) end def body_class diff --git a/app/helpers/browse_helper.rb b/app/helpers/browse_helper.rb index 2f61631b7..cf2bc6474 100644 --- a/app/helpers/browse_helper.rb +++ b/app/helpers/browse_helper.rb @@ -16,11 +16,11 @@ module BrowseHelper locale = available_locales.preferred(preferred_languages) if object.tags.include? "name:#{locale}" - name = t "printable_name.with_name_html", :name => content_tag(:bdi, object.tags["name:#{locale}"].to_s), :id => content_tag(:bdi, name) + name = t "printable_name.with_name_html", :name => tag.bdi(object.tags["name:#{locale}"].to_s), :id => tag.bdi(name) elsif object.tags.include? "name" - name = t "printable_name.with_name_html", :name => content_tag(:bdi, object.tags["name"].to_s), :id => content_tag(:bdi, name) + name = t "printable_name.with_name_html", :name => tag.bdi(object.tags["name"].to_s), :id => tag.bdi(name) elsif object.tags.include? "ref" - name = t "printable_name.with_name_html", :name => content_tag(:bdi, object.tags["ref"].to_s), :id => content_tag(:bdi, name) + name = t "printable_name.with_name_html", :name => tag.bdi(object.tags["ref"].to_s), :id => tag.bdi(name) end end diff --git a/app/helpers/browse_tags_helper.rb b/app/helpers/browse_tags_helper.rb index fc25325a4..5acbba9c7 100644 --- a/app/helpers/browse_tags_helper.rb +++ b/app/helpers/browse_tags_helper.rb @@ -30,7 +30,7 @@ module BrowseTagsHelper end safe_join(phones, "; ") elsif colour_value = colour_preview(key, value) - content_tag(:span, "", :class => "colour-preview-box", :"data-colour" => colour_value, :title => t("browse.tag_details.colour_preview", :colour_value => colour_value)) + colour_value + tag.span("", :class => "colour-preview-box", :"data-colour" => colour_value, :title => t("browse.tag_details.colour_preview", :colour_value => colour_value)) + colour_value else linkify h(value) end diff --git a/app/helpers/issues_helper.rb b/app/helpers/issues_helper.rb index 43ca98c91..e6c1adb16 100644 --- a/app/helpers/issues_helper.rb +++ b/app/helpers/issues_helper.rb @@ -28,9 +28,9 @@ module IssuesHelper def open_issues_count count = Issue.visible_to(current_user).open.limit(100).size if count > 99 - content_tag(:span, "99+", :class => "count-number") + tag.span("99+", :class => "count-number") elsif count.positive? - content_tag(:span, count, :class => "count-number") + tag.span(count, :class => "count-number") end end end diff --git a/app/helpers/notifier_helper.rb b/app/helpers/notifier_helper.rb index cc99898aa..c18f79903 100644 --- a/app/helpers/notifier_helper.rb +++ b/app/helpers/notifier_helper.rb @@ -5,8 +5,7 @@ module NotifierHelper def link_to_user(display_name) link_to( - content_tag( - "strong", + tag.strong( display_name, # NB we need "text-decoration: none" twice: GMail only honours it on # the but Outlook only on the diff --git a/app/helpers/user_roles_helper.rb b/app/helpers/user_roles_helper.rb index b9430535e..438076592 100644 --- a/app/helpers/user_roles_helper.rb +++ b/app/helpers/user_roles_helper.rb @@ -29,7 +29,7 @@ module UserRolesHelper if image svg_icon = tag("source", :srcset => image_path("#{image}.svg"), :type => "image/svg+xml") png_icon = image_tag("#{image}.png", :srcset => image_path("#{image}.svg"), :size => "20x20", :border => 0, :alt => alt, :title => title) - icon = content_tag("picture", svg_icon + png_icon) + icon = tag.picture(svg_icon + png_icon) icon = link_to(icon, url, :method => :post, :confirm => confirm) if url end diff --git a/app/models/issue.rb b/app/models/issue.rb index 14c5f8231..c0707728e 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -32,7 +32,7 @@ class Issue < ApplicationRecord belongs_to :reportable, :polymorphic => true - belongs_to :reported_user, :class_name => "User", :foreign_key => :reported_user_id + belongs_to :reported_user, :class_name => "User" belongs_to :user_resolved, :class_name => "User", :foreign_key => :resolved_by belongs_to :user_updated, :class_name => "User", :foreign_key => :updated_by diff --git a/app/models/note_comment.rb b/app/models/note_comment.rb index 9611cfe3a..eed917eee 100644 --- a/app/models/note_comment.rb +++ b/app/models/note_comment.rb @@ -24,8 +24,8 @@ # class NoteComment < ApplicationRecord - belongs_to :note, :foreign_key => :note_id, :touch => true - belongs_to :author, :class_name => "User", :foreign_key => :author_id + belongs_to :note, :touch => true + belongs_to :author, :class_name => "User" validates :id, :uniqueness => true, :presence => { :on => :update }, :numericality => { :on => :update, :only_integer => true } diff --git a/app/models/relation_member.rb b/app/models/relation_member.rb index 7f07dda9b..2de551c3f 100644 --- a/app/models/relation_member.rb +++ b/app/models/relation_member.rb @@ -21,6 +21,6 @@ class RelationMember < ApplicationRecord self.table_name = "current_relation_members" self.primary_keys = "relation_id", "sequence_id" - belongs_to :relation, :foreign_key => :relation_id + belongs_to :relation belongs_to :member, :polymorphic => true end diff --git a/app/models/user_block.rb b/app/models/user_block.rb index 9150bae79..47ff9ff08 100644 --- a/app/models/user_block.rb +++ b/app/models/user_block.rb @@ -28,9 +28,9 @@ class UserBlock < ApplicationRecord validate :moderator_permissions validates :reason, :characters => true - belongs_to :user, :class_name => "User", :foreign_key => :user_id - belongs_to :creator, :class_name => "User", :foreign_key => :creator_id - belongs_to :revoker, :class_name => "User", :foreign_key => :revoker_id + belongs_to :user, :class_name => "User" + belongs_to :creator, :class_name => "User" + belongs_to :revoker, :class_name => "User" PERIODS = Settings.user_block_periods -- 2.39.5