Fix new rubocop warnings

This commit is contained in:
Tom Hughes 2020-06-11 19:19:12 +01:00
parent 2c341c438a
commit 39b60219fe
10 changed files with 22 additions and 23 deletions

View file

@ -21,15 +21,15 @@ module ApplicationHelper
id = "#{object_name}_#{method}" id = "#{object_name}_#{method}"
type = options.delete(:format) || "markdown" type = options.delete(:format) || "markdown"
content_tag(:div, :id => "#{id}_container", :class => "richtext_container") do tag.div(:id => "#{id}_container", :class => "richtext_container") do
output_buffer << content_tag(:div, :id => "#{id}_content", :class => "richtext_content") 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 << 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 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 << 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.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") output_buffer << submit_tag(I18n.t("site.richtext_area.preview"), :id => "#{id}_dopreview", :class => "richtext_dopreview deemphasize")
end end
@ -46,11 +46,11 @@ module ApplicationHelper
end end
def friendly_date(date) 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 end
def friendly_date_ago(date) 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 end
def body_class def body_class

View file

@ -16,11 +16,11 @@ module BrowseHelper
locale = available_locales.preferred(preferred_languages) locale = available_locales.preferred(preferred_languages)
if object.tags.include? "name:#{locale}" 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" 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" 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
end end

View file

@ -30,7 +30,7 @@ module BrowseTagsHelper
end end
safe_join(phones, "; ") safe_join(phones, "; ")
elsif colour_value = colour_preview(key, value) 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 else
linkify h(value) linkify h(value)
end end

View file

@ -28,9 +28,9 @@ module IssuesHelper
def open_issues_count def open_issues_count
count = Issue.visible_to(current_user).open.limit(100).size count = Issue.visible_to(current_user).open.limit(100).size
if count > 99 if count > 99
content_tag(:span, "99+", :class => "count-number") tag.span("99+", :class => "count-number")
elsif count.positive? elsif count.positive?
content_tag(:span, count, :class => "count-number") tag.span(count, :class => "count-number")
end end
end end
end end

View file

@ -5,8 +5,7 @@ module NotifierHelper
def link_to_user(display_name) def link_to_user(display_name)
link_to( link_to(
content_tag( tag.strong(
"strong",
display_name, display_name,
# NB we need "text-decoration: none" twice: GMail only honours it on # NB we need "text-decoration: none" twice: GMail only honours it on
# the <a> but Outlook only on the <strong> # the <a> but Outlook only on the <strong>

View file

@ -29,7 +29,7 @@ module UserRolesHelper
if image if image
svg_icon = tag("source", :srcset => image_path("#{image}.svg"), :type => "image/svg+xml") 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) 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 icon = link_to(icon, url, :method => :post, :confirm => confirm) if url
end end

View file

@ -32,7 +32,7 @@
class Issue < ApplicationRecord class Issue < ApplicationRecord
belongs_to :reportable, :polymorphic => true 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_resolved, :class_name => "User", :foreign_key => :resolved_by
belongs_to :user_updated, :class_name => "User", :foreign_key => :updated_by belongs_to :user_updated, :class_name => "User", :foreign_key => :updated_by

View file

@ -24,8 +24,8 @@
# #
class NoteComment < ApplicationRecord class NoteComment < ApplicationRecord
belongs_to :note, :foreign_key => :note_id, :touch => true belongs_to :note, :touch => true
belongs_to :author, :class_name => "User", :foreign_key => :author_id belongs_to :author, :class_name => "User"
validates :id, :uniqueness => true, :presence => { :on => :update }, validates :id, :uniqueness => true, :presence => { :on => :update },
:numericality => { :on => :update, :only_integer => true } :numericality => { :on => :update, :only_integer => true }

View file

@ -21,6 +21,6 @@ class RelationMember < ApplicationRecord
self.table_name = "current_relation_members" self.table_name = "current_relation_members"
self.primary_keys = "relation_id", "sequence_id" self.primary_keys = "relation_id", "sequence_id"
belongs_to :relation, :foreign_key => :relation_id belongs_to :relation
belongs_to :member, :polymorphic => true belongs_to :member, :polymorphic => true
end end

View file

@ -28,9 +28,9 @@ class UserBlock < ApplicationRecord
validate :moderator_permissions validate :moderator_permissions
validates :reason, :characters => true validates :reason, :characters => true
belongs_to :user, :class_name => "User", :foreign_key => :user_id belongs_to :user, :class_name => "User"
belongs_to :creator, :class_name => "User", :foreign_key => :creator_id belongs_to :creator, :class_name => "User"
belongs_to :revoker, :class_name => "User", :foreign_key => :revoker_id belongs_to :revoker, :class_name => "User"
PERIODS = Settings.user_block_periods PERIODS = Settings.user_block_periods