From c926f5fd6764aa4dcc7a3da826a91d2d6bd4a5c7 Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Wed, 25 Oct 2023 08:01:00 -0400 Subject: [PATCH] Fix haml-lint `UnnecessaryStringOutput` for views (#27531) --- .haml-lint_todo.yml | 20 ------------------- app/views/accounts/show.html.haml | 2 +- .../custom_emojis/_custom_emoji.html.haml | 2 +- app/views/admin/relays/_relay.html.haml | 6 +++--- app/views/admin/rules/_rule.html.haml | 2 +- app/views/admin/statuses/index.html.haml | 2 +- .../auth/registrations/_session.html.haml | 2 +- app/views/disputes/strikes/show.html.haml | 4 ++-- .../notification_mailer/_status.html.haml | 2 +- .../index.html.haml | 2 +- app/views/statuses/_detailed_status.html.haml | 6 +++--- app/views/statuses/_poll.html.haml | 2 +- app/views/statuses/_simple_status.html.haml | 2 +- .../user_mailer/suspicious_sign_in.html.haml | 4 ++-- .../webauthn_credential_added.html.haml | 2 +- .../webauthn_credential_deleted.html.haml | 2 +- app/views/user_mailer/welcome.html.haml | 2 +- 17 files changed, 22 insertions(+), 42 deletions(-) diff --git a/.haml-lint_todo.yml b/.haml-lint_todo.yml index c7209cdf7..c3cca9c9a 100644 --- a/.haml-lint_todo.yml +++ b/.haml-lint_todo.yml @@ -11,26 +11,6 @@ linters: LineLength: enabled: false - # Offense count: 22 - UnnecessaryStringOutput: - exclude: - - 'app/views/accounts/show.html.haml' - - 'app/views/admin/custom_emojis/_custom_emoji.html.haml' - - 'app/views/admin/relays/_relay.html.haml' - - 'app/views/admin/rules/_rule.html.haml' - - 'app/views/admin/statuses/index.html.haml' - - 'app/views/auth/registrations/_session.html.haml' - - 'app/views/disputes/strikes/show.html.haml' - - 'app/views/notification_mailer/_status.html.haml' - - 'app/views/settings/two_factor_authentication_methods/index.html.haml' - - 'app/views/statuses/_detailed_status.html.haml' - - 'app/views/statuses/_poll.html.haml' - - 'app/views/statuses/_simple_status.html.haml' - - 'app/views/user_mailer/suspicious_sign_in.html.haml' - - 'app/views/user_mailer/webauthn_credential_added.html.haml' - - 'app/views/user_mailer/webauthn_credential_deleted.html.haml' - - 'app/views/user_mailer/welcome.html.haml' - # Offense count: 45 RuboCop: exclude: diff --git a/app/views/accounts/show.html.haml b/app/views/accounts/show.html.haml index e8fd27e10..d56f10a7f 100644 --- a/app/views/accounts/show.html.haml +++ b/app/views/accounts/show.html.haml @@ -1,5 +1,5 @@ - content_for :page_title do - = "#{display_name(@account)} (#{acct(@account)})" + #{display_name(@account)} (#{acct(@account)}) - content_for :header_tags do - if @account.user_prefers_noindex? diff --git a/app/views/admin/custom_emojis/_custom_emoji.html.haml b/app/views/admin/custom_emojis/_custom_emoji.html.haml index c6789d4f8..f0cb64ec5 100644 --- a/app/views/admin/custom_emojis/_custom_emoji.html.haml +++ b/app/views/admin/custom_emojis/_custom_emoji.html.haml @@ -6,7 +6,7 @@ = custom_emoji_tag(custom_emoji) .batch-table__row__content__text - %samp= ":#{custom_emoji.shortcode}:" + %samp :#{custom_emoji.shortcode}: - if custom_emoji.local? %span.information-badge= custom_emoji.category&.name || t('admin.custom_emojis.uncategorized') diff --git a/app/views/admin/relays/_relay.html.haml b/app/views/admin/relays/_relay.html.haml index 667821894..f1dd2b2dd 100644 --- a/app/views/admin/relays/_relay.html.haml +++ b/app/views/admin/relays/_relay.html.haml @@ -5,16 +5,16 @@ - if relay.accepted? %span.positive-hint = fa_icon('check') - = ' ' +   = t 'admin.relays.enabled' - elsif relay.pending? = fa_icon('hourglass') - = ' ' +   = t 'admin.relays.pending' - else %span.negative-hint = fa_icon('times') - = ' ' +   = t 'admin.relays.disabled' %td - if relay.accepted? diff --git a/app/views/admin/rules/_rule.html.haml b/app/views/admin/rules/_rule.html.haml index f8a9ac786..a0896fe80 100644 --- a/app/views/admin/rules/_rule.html.haml +++ b/app/views/admin/rules/_rule.html.haml @@ -1,6 +1,6 @@ .announcements-list__item = link_to edit_admin_rule_path(rule), class: 'announcements-list__item__title' do - = "#{rule_counter + 1}." + #{rule_counter + 1}. = truncate(rule.text) .announcements-list__item__action-bar diff --git a/app/views/admin/statuses/index.html.haml b/app/views/admin/statuses/index.html.haml index 9163dee79..a2e3cbc0d 100644 --- a/app/views/admin/statuses/index.html.haml +++ b/app/views/admin/statuses/index.html.haml @@ -1,7 +1,7 @@ - content_for :page_title do = t('admin.statuses.title') \- - = "@#{@account.pretty_acct}" + @#{@account.pretty_acct} .filters .filter-subset diff --git a/app/views/auth/registrations/_session.html.haml b/app/views/auth/registrations/_session.html.haml index 11eae566f..28499a7c9 100644 --- a/app/views/auth/registrations/_session.html.haml +++ b/app/views/auth/registrations/_session.html.haml @@ -2,7 +2,7 @@ %td %span{ title: session.user_agent }< = fa_icon "#{session_device_icon(session)} fw", 'aria-label': session_device_icon(session) - = ' ' +   = t 'sessions.description', browser: t("sessions.browsers.#{session.browser}", default: session.browser.to_s), platform: t("sessions.platforms.#{session.platform}", default: session.platform.to_s) %td %samp= session.ip diff --git a/app/views/disputes/strikes/show.html.haml b/app/views/disputes/strikes/show.html.haml index 1c16e0bbf..62695b155 100644 --- a/app/views/disputes/strikes/show.html.haml +++ b/app/views/disputes/strikes/show.html.haml @@ -10,13 +10,13 @@ %p.hint %span.positive-hint = fa_icon 'check' - = ' ' +   = t 'disputes.strikes.appeal_approved' - elsif @appeal.persisted? && @appeal.rejected? %p.hint %span.negative-hint = fa_icon 'times' - = ' ' +   = t 'disputes.strikes.appeal_rejected' .report-header diff --git a/app/views/notification_mailer/_status.html.haml b/app/views/notification_mailer/_status.html.haml index 7f614e99c..e053a30fd 100644 --- a/app/views/notification_mailer/_status.html.haml +++ b/app/views/notification_mailer/_status.html.haml @@ -23,7 +23,7 @@ = image_tag full_asset_url(status.account.avatar.url), alt: '' %td{ align: 'left' } %bdi= display_name(status.account) - = "@#{status.account.pretty_acct}" + @#{status.account.pretty_acct} - if status.spoiler_text? .auto-dir diff --git a/app/views/settings/two_factor_authentication_methods/index.html.haml b/app/views/settings/two_factor_authentication_methods/index.html.haml index 315443e6d..51141fab4 100644 --- a/app/views/settings/two_factor_authentication_methods/index.html.haml +++ b/app/views/settings/two_factor_authentication_methods/index.html.haml @@ -7,7 +7,7 @@ %p.hint %span.positive-hint = fa_icon 'check' - = ' ' +   = t 'two_factor_authentication.enabled' .table-wrapper diff --git a/app/views/statuses/_detailed_status.html.haml b/app/views/statuses/_detailed_status.html.haml index 9e171ff59..c55dff5d9 100644 --- a/app/views/statuses/_detailed_status.html.haml +++ b/app/views/statuses/_detailed_status.html.haml @@ -62,18 +62,18 @@ - else = fa_icon('reply-all') %span.detailed-status__reblogs>= friendly_number_to_human status.replies_count - = ' ' +   · - if status.public_visibility? || status.unlisted_visibility? %span.detailed-status__link = fa_icon('retweet') %span.detailed-status__reblogs>= friendly_number_to_human status.reblogs_count - = ' ' +   · %span.detailed-status__link = fa_icon('star') %span.detailed-status__favorites>= friendly_number_to_human status.favourites_count - = ' ' +   - if user_signed_in? · diff --git a/app/views/statuses/_poll.html.haml b/app/views/statuses/_poll.html.haml index b537eb48c..cf01b1da0 100644 --- a/app/views/statuses/_poll.html.haml +++ b/app/views/statuses/_poll.html.haml @@ -11,7 +11,7 @@ - percent = total_votes_count.positive? ? 100 * option.votes_count / total_votes_count : 0 %label.poll__option>< %span.poll__number>< - = "#{percent.round}%" + #{percent.round}% %span.poll__option__text = prerender_custom_emojis(h(option.title), status.emojis) - if own_votes.include?(index) diff --git a/app/views/statuses/_simple_status.html.haml b/app/views/statuses/_simple_status.html.haml index 32584c92a..93effc452 100644 --- a/app/views/statuses/_simple_status.html.haml +++ b/app/views/statuses/_simple_status.html.haml @@ -23,7 +23,7 @@ %span.display-name %bdi %strong.display-name__html.p-name.emojify= display_name(status.account, custom_emojify: true, autoplay: prefers_autoplay?) - = ' ' +   %span.display-name__account = acct(status.account) = fa_icon('lock') if status.account.locked? diff --git a/app/views/user_mailer/suspicious_sign_in.html.haml b/app/views/user_mailer/suspicious_sign_in.html.haml index 75bcb2d54..5bafe9d1b 100644 --- a/app/views/user_mailer/suspicious_sign_in.html.haml +++ b/app/views/user_mailer/suspicious_sign_in.html.haml @@ -41,10 +41,10 @@ %tr %td.column-cell.text-center %p - %strong= "#{t('sessions.ip')}:" + %strong #{t('sessions.ip')}: = @remote_ip %br/ - %strong= "#{t('sessions.browser')}:" + %strong #{t('sessions.browser')}: %span{ title: @user_agent }= t 'sessions.description', browser: t("sessions.browsers.#{@detection.id}", default: @detection.id.to_s), platform: t("sessions.platforms.#{@detection.platform.id}", default: @detection.platform.id.to_s) %br/ = l(@timestamp.in_time_zone(@resource.time_zone.presence), format: :with_time_zone) diff --git a/app/views/user_mailer/webauthn_credential_added.html.haml b/app/views/user_mailer/webauthn_credential_added.html.haml index c91c96d6f..2ecb62d96 100644 --- a/app/views/user_mailer/webauthn_credential_added.html.haml +++ b/app/views/user_mailer/webauthn_credential_added.html.haml @@ -20,7 +20,7 @@ = image_tag full_pack_url('media/images/mailer/icon_lock_open.png'), alt: '' %h1= t 'devise.mailer.webauthn_credential.added.title' - %p.lead= "#{t('devise.mailer.webauthn_credential.added.explanation')}:" + %p.lead #{t('devise.mailer.webauthn_credential.added.explanation')}: %p.lead= @webauthn_credential.nickname %table.email-table{ cellspacing: 0, cellpadding: 0 } diff --git a/app/views/user_mailer/webauthn_credential_deleted.html.haml b/app/views/user_mailer/webauthn_credential_deleted.html.haml index 578a08022..f282985b1 100644 --- a/app/views/user_mailer/webauthn_credential_deleted.html.haml +++ b/app/views/user_mailer/webauthn_credential_deleted.html.haml @@ -20,7 +20,7 @@ = image_tag full_pack_url('media/images/mailer/icon_lock_open.png'), alt: '' %h1= t 'devise.mailer.webauthn_credential.deleted.title' - %p.lead= "#{t('devise.mailer.webauthn_credential.deleted.explanation')}:" + %p.lead #{t('devise.mailer.webauthn_credential.deleted.explanation')}: %p.lead= @webauthn_credential.nickname %table.email-table{ cellspacing: 0, cellpadding: 0 } diff --git a/app/views/user_mailer/welcome.html.haml b/app/views/user_mailer/welcome.html.haml index 3ab994ad3..0d8a15cfd 100644 --- a/app/views/user_mailer/welcome.html.haml +++ b/app/views/user_mailer/welcome.html.haml @@ -41,7 +41,7 @@ %table.input{ align: 'center', cellspacing: 0, cellpadding: 0 } %tbody %tr - %td= "@#{@resource.account.username}@#{@instance}" + %td @#{@resource.account.username}@#{@instance} .col-3 %table.column{ cellspacing: 0, cellpadding: 0 } %tbody