Skip to content

Commit

Permalink
Auto-correct RuboCop offenses for Rails/ContentTag
Browse files Browse the repository at this point in the history
This cop was introduced in rubocop-rails 2.6.0
  • Loading branch information
Dany Marcoux committed Jun 9, 2020
1 parent 7fd2067 commit 0557f72
Show file tree
Hide file tree
Showing 13 changed files with 48 additions and 48 deletions.
4 changes: 2 additions & 2 deletions src/api/app/datatables/excluded_request_datatable.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
class ExcludedRequestDatatable < Datatable
def_delegators :@view, :link_to, :excluded_request_path, :content_tag, :request_show_path
def_delegators :@view, :link_to, :excluded_request_path, :tag, :request_show_path

def initialize(params, opts = {})
@staging_workflow = opts[:staging_workflow]
Expand Down Expand Up @@ -40,7 +40,7 @@ def process_policy(excluded_request)
def link_to_delete(request_exclusion)
link_to('#', title: 'Include back this request?', data: { toggle: 'modal', target: '#delete-excluded-request-modal',
action: excluded_request_path(@staging_workflow.project, request_exclusion) }) do
content_tag(:i, nil, class: 'fas fa-times-circle text-danger')
tag.i(nil, class: 'fas fa-times-circle text-danger')
end
end
end
4 changes: 2 additions & 2 deletions src/api/app/datatables/maintained_project_datatable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ class MaintainedProjectDatatable < Datatable
def_delegator :@view, :project_show_path
def_delegator :@view, :policy
def_delegator :@view, :project_maintained_project_path
def_delegator :@view, :content_tag
def_delegator :@view, :tag

def initialize(params, opts = {})
@project = opts[:project]
Expand Down Expand Up @@ -42,7 +42,7 @@ def process_policy(project_name)
def link_to_delete(project_name)
link_to('#', title: 'Delete Project', data: { toggle: 'modal', target: '#delete-maintained-project-modal',
action: project_maintained_project_path(project_name: @project, maintained_project: project_name) }) do
content_tag(:i, nil, class: 'fas fa-times-circle text-danger')
tag.i(nil, class: 'fas fa-times-circle text-danger')
end
end
end
4 changes: 2 additions & 2 deletions src/api/app/datatables/package_datatable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ class PackageDatatable < Datatable
def_delegator :@view, :link_to
def_delegator :@view, :package_show_path
def_delegator :@view, :time_ago_in_words
def_delegator :@view, :content_tag
def_delegator :@view, :tag
def_delegator :@view, :safe_join

def initialize(params, opts = {})
Expand Down Expand Up @@ -39,7 +39,7 @@ def data
def name_with_link(record)
name = []
name << link_to(record.name, package_show_path(package: record, project: @project))
name << content_tag(:span, 'Link', class: 'badge badge-info') if record.is_link?
name << tag.span('Link', class: 'badge badge-info') if record.is_link?
safe_join(name, ' ')
end
end
8 changes: 4 additions & 4 deletions src/api/app/helpers/webui/buildresult_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ def arch_repo_table_cell(repo, arch, package_name, status = nil, enable_help = t

capture do
if enable_help && status['code']
concat(content_tag(:i, nil, class: ['fa', 'fa-question-circle', 'text-info', 'mr-1'],
data: { content: Buildresult.status_description(status['code']), placement: 'top', toggle: 'popover' }))
concat(tag.i(nil, class: ['fa', 'fa-question-circle', 'text-info', 'mr-1'],
data: { content: Buildresult.status_description(status['code']), placement: 'top', toggle: 'popover' }))
end
if code.in?(['-', 'unresolvable', 'blocked', 'excluded', 'scheduled'])
concat(link_to(code, 'javascript:void(0);', id: status_id, class: theclass, data: { content: link_title, placement: 'right', toggle: 'popover' }))
Expand Down Expand Up @@ -59,8 +59,8 @@ def collapse_link(expanded, main_name, repository_name = nil)
link_to('#', aria: { controls: "collapse-#{collapse_id}", expanded: expanded }, class: 'px-2 ml-auto',
data: { toggle: 'collapse' }, href: ".collapse-#{collapse_id}", role: 'button') do
capture do
concat(content_tag(:i, nil, class: ['fas', 'fa-chevron-left', 'expander'], title: "Show build results for this #{collapse_text}"))
concat(content_tag(:i, nil, class: ['fas', 'fa-chevron-down', 'collapser'], title: "Hide build results for this #{collapse_text}"))
concat(tag.i(nil, class: ['fas', 'fa-chevron-left', 'expander'], title: "Show build results for this #{collapse_text}"))
concat(tag.i(nil, class: ['fas', 'fa-chevron-down', 'collapser'], title: "Hide build results for this #{collapse_text}"))
end
end
end
Expand Down
20 changes: 10 additions & 10 deletions src/api/app/helpers/webui/maintenance_incident_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ def open_requests_icon(incident)

path = (requests.count == 1 ? request_show_path(requests.first) : project_requests_path(project: incident.name))

content_tag(:div) do
tag.div do
link_to(path) do
concat content_tag(:i, nil, class: 'fas fa-exclamation-circle text-danger pr-1')
concat tag.i(nil, class: 'fas fa-exclamation-circle text-danger pr-1')
concat pluralize(requests.count, 'open request')
end
end
Expand All @@ -29,8 +29,8 @@ def outgoing_requests_icons(incident)
if requests.present?
safe_join(outgoing_request_links(requests), '<div/>'.html_safe)
elsif incident.is_locked?
content_tag(:div) do
concat content_tag(:i, nil, class: 'fas fa-lock text-info pr-1')
tag.div do
concat tag.i(nil, class: 'fas fa-lock text-info pr-1')
concat 'Locked'
end
end
Expand All @@ -53,7 +53,7 @@ def category_cell(incident, patchinfo)
class: "patchinfo-category-#{patchinfo[:category]}")
else
link_to(patchinfo_path(project: incident.name, package: 'patchinfo'), method: :post, class: 'text-danger') do
content_tag(:i, nil, class: 'fas fa-exclamation-circle text-danger')
tag.i(nil, class: 'fas fa-exclamation-circle text-danger')
'Missing Patchinfo'
end
end
Expand All @@ -77,20 +77,20 @@ def info_cell(incident, patchinfo)
def stopped_icon(patchinfo)
return unless patchinfo[:stopped]

content_tag(:div) do
safe_join([content_tag(:i, nil, class: 'fas fa-clock text-info pr-1'), "Stopped: #{patchinfo[:stopped]}"])
tag.div do
safe_join([tag.i(nil, class: 'fas fa-clock text-info pr-1'), "Stopped: #{patchinfo[:stopped]}"])
end
end

def release_targets_cell(incident)
safe_join(
[
incident.target_repositories.map do |target_repo|
content_tag(:div) do
tag.div do
safe_join(
[
link_to(project_show_path(project: incident.name)) do
content_tag(:i, nil, class: "fas pr-1 #{incident_build_icon_class(incident, target_repo.name)}", title: 'Build results')
tag.i(nil, class: "fas pr-1 #{incident_build_icon_class(incident, target_repo.name)}", title: 'Build results')
end,
link_to(target_repo.project, project_show_path(project: target_repo.project))
]
Expand All @@ -108,7 +108,7 @@ def outgoing_request_links(requests)
safe_join(
[
link_to(request_show_path(request['number'])) do
content_tag(:i, nil, class: "fas fa-flag pr-1 request-flag-#{request['state']}", title: "Release request in state '#{request['state']}'")
tag.i(nil, class: "fas fa-flag pr-1 request-flag-#{request['state']}", title: "Release request in state '#{request['state']}'")
end,
# rubocop:disable Rails/OutputSafety
"Created #{fuzzy_time(request.created_at)}".html_safe
Expand Down
2 changes: 1 addition & 1 deletion src/api/app/helpers/webui/notification_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def filter_by_project_link(link_text, amount, filter_item)
link_to(my_notifications_path(filter_item), class: filter_css(filter_item)) do
capture do
concat(link_text)
concat(content_tag(:span, amount, class: "badge #{badge_color} align-text-top ml-2"))
concat(tag.span(amount, class: "badge #{badge_color} align-text-top ml-2"))
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion src/api/app/helpers/webui/projects/category_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ def category_badge(category)
else
'badge-dark'
end
content_tag(:span, category, class: "quality-category badge ml-1 #{badge_type}")
tag.span(category, class: "quality-category badge ml-1 #{badge_type}")
end
end
10 changes: 5 additions & 5 deletions src/api/app/helpers/webui/repository_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ def flag_column(flags, repository, architecture)
data['user-set'] = 1
end

content_tag(:div) do
content_tag(:i, nil, class: 'fas fa-spinner fa-spin d-none') +
tag.div do
tag.i(nil, class: 'fas fa-spinner fa-spin d-none') +
link_to('javascript:;', title: title(flag, is_flag_set_by_user), class: 'flag-popup', data: data) do
content_tag(:span, class: 'text-nowrap current_flag_state') do
content_tag(:i, nil, class: icon_class(flag, is_flag_set_by_user)) +
tag.span(class: 'text-nowrap current_flag_state') do
tag.i(nil, class: icon_class(flag, is_flag_set_by_user)) +
if is_flag_set_by_user
content_tag(:i, nil, class: 'fas fa-circle text-gray-500 text-40p-size')
tag.i(nil, class: 'fas fa-circle text-gray-500 text-40p-size')
end
end
end
Expand Down
12 changes: 6 additions & 6 deletions src/api/app/helpers/webui/staging/workflow_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ def reviewers_icon(request, users_hash, groups_hash)
when 'by_user'
tags << image_tag_for(users_hash[review[:by]], size: 20)
when 'by_project'
tags << content_tag(:i, nil, class: 'fa fa-cubes', title: review[:by])
tags << tag.i(nil, class: 'fa fa-cubes', title: review[:by])
when 'by_package'
tags << content_tag(:i, nil, class: 'fa fa-archive', title: review[:by])
tags << tag.i(nil, class: 'fa fa-archive', title: review[:by])
end
end
tags
Expand All @@ -70,7 +70,7 @@ def create_request_links(request, users_hash, groups_hash)
css += ' delete' if request[:request_type] == 'delete'
link_content = [request[:package]]
link_content << reviewers_icon(request, users_hash, groups_hash) if request[:missing_reviews].present?
content_tag(:span, class: "badge state-#{css}") do
tag.span(class: "badge state-#{css}") do
link_to(request_show_path(request[:number]), class: 'request') do
safe_join(link_content)
end
Expand All @@ -97,11 +97,11 @@ def requests(staging_project, users_hash, groups_hash)
output += link_to('#', class: 'collapsed', 'data-toggle': 'collapse', href: ".collapse-#{staging_project.id}",
role: 'button', aria: { expanded: 'false', controls: "collapse-#{staging_project.id}" }) do
safe_join([
content_tag(:i, nil, class: 'fas fa-chevron-up collapser text-secondary ml-1 mr-1'),
content_tag(:i, nil, class: 'fas fa-chevron-down expander text-secondary ml-1 mr-1')
tag.i(nil, class: 'fas fa-chevron-up collapser text-secondary ml-1 mr-1'),
tag.i(nil, class: 'fas fa-chevron-down expander text-secondary ml-1 mr-1')
])
end
output + content_tag(:div, class: "collapse collapse-#{staging_project.id}") do
output + tag.div(class: "collapse collapse-#{staging_project.id}") do
safe_join(requests_links[requests_visible_by_default..-1])
end
end
Expand Down
6 changes: 3 additions & 3 deletions src/api/app/helpers/webui/user_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ def user_actions(user)
safe_join(
[
link_to(edit_user_path(user.login)) do
content_tag(:i, nil, class: 'fas fa-edit text-secondary pr-1', title: 'Edit User')
tag.i(nil, class: 'fas fa-edit text-secondary pr-1', title: 'Edit User')
end,
mail_to(user.email) do
content_tag(:i, nil, class: 'fas fa-envelope text-secondary pr-1', title: 'Send Email to User')
tag.i(nil, class: 'fas fa-envelope text-secondary pr-1', title: 'Send Email to User')
end,
link_to(user_path(user.login), method: :delete, data: { confirm: 'Are you sure?' }) do
content_tag(:i, nil, class: 'fas fa-times-circle text-danger pr-1', title: 'Delete User')
tag.i(nil, class: 'fas fa-times-circle text-danger pr-1', title: 'Delete User')
end
]
)
Expand Down
6 changes: 3 additions & 3 deletions src/api/app/helpers/webui/user_or_groups_roles_helper.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
module Webui::UserOrGroupsRolesHelper
def display_name(object)
if object.is_a?(User) && object.realname.present?
content_tag :span do
tag.span do
concat "#{object.name} ("
concat content_tag(:i, object.login)
concat tag.i(object.login)
concat ')'
end
else
content_tag(:span, object.name)
tag.span(object.name)
end
end

Expand Down
14 changes: 7 additions & 7 deletions src/api/app/helpers/webui/webui_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def repository_status_icon(status:, details: nil, html_class: '')

data_options = {}
data_options.merge!(content: description, placement: 'top', toggle: 'popover') unless flipper_responsive?
content_tag(:i, '', class: "repository-state-#{repo_state_class} #{html_class} fas fa-#{repo_status_icon(status)}", data: data_options)
tag.i('', class: "repository-state-#{repo_state_class} #{html_class} fas fa-#{repo_status_icon(status)}", data: data_options)
end

# NOTE: reponsive_ux
Expand Down Expand Up @@ -286,12 +286,12 @@ def toggle_sliced_text(text, slice_length = 50, id = "toggle_sliced_text_#{Time.
return text if text.to_s.length < slice_length

javascript_toggle_code = "$(\"[data-toggle-id='".html_safe + id + "']\").toggle();".html_safe
short = content_tag(:span, 'data-toggle-id' => id) do
content_tag(:span, text.slice(0, slice_length) + ' ') +
short = tag.span('data-toggle-id' => id) do
tag.span(text.slice(0, slice_length) + ' ') +
link_to('[+]', 'javascript:void(0)', onclick: javascript_toggle_code)
end
long = content_tag(:span, 'data-toggle-id' => id, :style => 'display: none;') do
content_tag(:span, text + ' ') +
long = tag.span('data-toggle-id' => id, :style => 'display: none;') do
tag.span(text + ' ') +
link_to('[-]', 'javascript:void(0)', onclick: javascript_toggle_code)
end
short + long
Expand Down Expand Up @@ -379,8 +379,8 @@ def log_in_link(css_class: nil)
def link_content(text, css_class, icon)
if css_class && css_class.include?('nav-link')
capture do
concat(content_tag(:i, '', class: "fas #{icon}"))
concat(content_tag(:div, text, class: 'small'))
concat(tag.i('', class: "fas #{icon}"))
concat(tag.div(text, class: 'small'))
end
else
text
Expand Down
4 changes: 2 additions & 2 deletions src/api/app/views/webui/package/_rpmlint_log.html.haml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
-# FIXME: move this into a helper
- @log.lines.each do |line|
- if /\w+(?:\.\w+)+: W: /.match?(line)
= content_tag(:span, line.strip, style: 'color: olive;')
= tag.span(line.strip, style: 'color: olive;')
- elsif /\w+(?:\.\w+)+: E: /.match?(line)
= content_tag(:span, line.strip, style: 'color: red;')
= tag.span(line.strip, style: 'color: red;')
- else
= line.strip

0 comments on commit 0557f72

Please sign in to comment.