Skip to content

Commit

Permalink
Fix haml-lint UnnecessaryStringOutput for views (mastodon#27531)
Browse files Browse the repository at this point in the history
  • Loading branch information
mjankowski authored Oct 25, 2023
1 parent c85e0a6 commit c926f5f
Show file tree
Hide file tree
Showing 17 changed files with 22 additions and 42 deletions.
20 changes: 0 additions & 20 deletions .haml-lint_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion app/views/accounts/show.html.haml
Original file line number Diff line number Diff line change
@@ -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?
Expand Down
2 changes: 1 addition & 1 deletion app/views/admin/custom_emojis/_custom_emoji.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
6 changes: 3 additions & 3 deletions app/views/admin/relays/_relay.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down
2 changes: 1 addition & 1 deletion app/views/admin/rules/_rule.html.haml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion app/views/admin/statuses/index.html.haml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
- content_for :page_title do
= t('admin.statuses.title')
\-
= "@#{@account.pretty_acct}"
@#{@account.pretty_acct}

.filters
.filter-subset
Expand Down
2 changes: 1 addition & 1 deletion app/views/auth/registrations/_session.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
%td
%span{ title: session.user_agent }<
= fa_icon "#{session_device_icon(session)} fw", 'aria-label': session_device_icon(session)
= ' '
&nbsp;
= 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
Expand Down
4 changes: 2 additions & 2 deletions app/views/disputes/strikes/show.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
%p.hint
%span.positive-hint
= fa_icon 'check'
= ' '
&nbsp;
= t 'disputes.strikes.appeal_approved'
- elsif @appeal.persisted? && @appeal.rejected?
%p.hint
%span.negative-hint
= fa_icon 'times'
= ' '
&nbsp;
= t 'disputes.strikes.appeal_rejected'

.report-header
Expand Down
2 changes: 1 addition & 1 deletion app/views/notification_mailer/_status.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
%p.hint
%span.positive-hint
= fa_icon 'check'
= ' '
&nbsp;
= t 'two_factor_authentication.enabled'

.table-wrapper
Expand Down
6 changes: 3 additions & 3 deletions app/views/statuses/_detailed_status.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -62,18 +62,18 @@
- else
= fa_icon('reply-all')
%span.detailed-status__reblogs>= friendly_number_to_human status.replies_count
= ' '
&nbsp;
·
- 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
= ' '
&nbsp;
·
%span.detailed-status__link
= fa_icon('star')
%span.detailed-status__favorites>= friendly_number_to_human status.favourites_count
= ' '
&nbsp;

- if user_signed_in?
·
Expand Down
2 changes: 1 addition & 1 deletion app/views/statuses/_poll.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion app/views/statuses/_simple_status.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -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?)
= ' '
&nbsp;
%span.display-name__account
= acct(status.account)
= fa_icon('lock') if status.account.locked?
Expand Down
4 changes: 2 additions & 2 deletions app/views/user_mailer/suspicious_sign_in.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion app/views/user_mailer/webauthn_credential_added.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
2 changes: 1 addition & 1 deletion app/views/user_mailer/welcome.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit c926f5f

Please sign in to comment.