Fix Rails/CompactBlank cop (#24690)
This commit is contained in:
parent
d00e45a7d3
commit
d902a707a3
@ -1203,16 +1203,6 @@ Rails/BulkChangeTable:
|
||||
- 'db/migrate/20220303000827_add_ordered_media_attachment_ids_to_status_edits.rb'
|
||||
- 'db/migrate/20220824164433_add_human_identifier_to_admin_action_logs.rb'
|
||||
|
||||
# This cop supports unsafe autocorrection (--autocorrect-all).
|
||||
Rails/CompactBlank:
|
||||
Exclude:
|
||||
- 'app/helpers/application_helper.rb'
|
||||
- 'app/helpers/statuses_helper.rb'
|
||||
- 'app/models/concerns/attachmentable.rb'
|
||||
- 'app/models/poll.rb'
|
||||
- 'app/services/import_service.rb'
|
||||
- 'config/initializers/paperclip.rb'
|
||||
|
||||
# Configuration parameters: Include.
|
||||
# Include: db/migrate/*.rb
|
||||
Rails/CreateTableWithTimestamps:
|
||||
|
@ -161,7 +161,7 @@ module ApplicationHelper
|
||||
output << 'system-font' if current_account&.user&.setting_system_font_ui
|
||||
output << (current_account&.user&.setting_reduce_motion ? 'reduce-motion' : 'no-reduce-motion')
|
||||
output << 'rtl' if locale_direction == 'rtl'
|
||||
output.reject(&:blank?).join(' ')
|
||||
output.compact_blank.join(' ')
|
||||
end
|
||||
|
||||
def cdn_host
|
||||
|
@ -51,14 +51,14 @@ module StatusesHelper
|
||||
end
|
||||
|
||||
def status_description(status)
|
||||
components = [[media_summary(status), status_text_summary(status)].reject(&:blank?).join(' · ')]
|
||||
components = [[media_summary(status), status_text_summary(status)].compact_blank.join(' · ')]
|
||||
|
||||
if status.spoiler_text.blank?
|
||||
components << status.text
|
||||
components << poll_summary(status)
|
||||
end
|
||||
|
||||
components.reject(&:blank?).join("\n\n")
|
||||
components.compact_blank.join("\n\n")
|
||||
end
|
||||
|
||||
def stream_link_target
|
||||
|
@ -46,7 +46,7 @@ module Attachmentable
|
||||
def set_file_extension(attachment) # rubocop:disable Naming/AccessorMethodName
|
||||
return if attachment.blank?
|
||||
|
||||
attachment.instance_write :file_name, [Paperclip::Interpolations.basename(attachment, :original), appropriate_extension(attachment)].delete_if(&:blank?).join('.')
|
||||
attachment.instance_write :file_name, [Paperclip::Interpolations.basename(attachment, :original), appropriate_extension(attachment)].compact_blank!.join('.')
|
||||
end
|
||||
|
||||
def check_image_dimension(attachment)
|
||||
|
@ -101,7 +101,7 @@ class Poll < ApplicationRecord
|
||||
end
|
||||
|
||||
def prepare_options
|
||||
self.options = options.map(&:strip).reject(&:blank?)
|
||||
self.options = options.map(&:strip).compact_blank
|
||||
end
|
||||
|
||||
def reset_parent_cache
|
||||
|
@ -445,7 +445,6 @@ class User < ApplicationRecord
|
||||
return if chosen_languages.nil?
|
||||
|
||||
chosen_languages.compact_blank!
|
||||
|
||||
self.chosen_languages = nil if chosen_languages.empty?
|
||||
end
|
||||
|
||||
|
@ -132,7 +132,7 @@ class ImportService < BaseService
|
||||
def parse_import_data!(default_headers)
|
||||
data = CSV.parse(import_data, headers: true)
|
||||
data = CSV.parse(import_data, headers: default_headers) unless data.headers&.first&.strip&.include?(' ')
|
||||
@data = data.reject(&:blank?)
|
||||
@data = data.compact_blank
|
||||
end
|
||||
|
||||
def import_data
|
||||
|
@ -7,7 +7,7 @@ Paperclip.interpolates :filename do |attachment, style|
|
||||
if style == :original
|
||||
attachment.original_filename
|
||||
else
|
||||
[basename(attachment, style), extension(attachment, style)].delete_if(&:blank?).join('.')
|
||||
[basename(attachment, style), extension(attachment, style)].compact_blank!.join('.')
|
||||
end
|
||||
end
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user