Fix Rails/CompactBlank cop (#24690)
parent
d00e45a7d3
commit
d902a707a3
|
@ -1203,16 +1203,6 @@ Rails/BulkChangeTable:
|
||||||
- 'db/migrate/20220303000827_add_ordered_media_attachment_ids_to_status_edits.rb'
|
- 'db/migrate/20220303000827_add_ordered_media_attachment_ids_to_status_edits.rb'
|
||||||
- 'db/migrate/20220824164433_add_human_identifier_to_admin_action_logs.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.
|
# Configuration parameters: Include.
|
||||||
# Include: db/migrate/*.rb
|
# Include: db/migrate/*.rb
|
||||||
Rails/CreateTableWithTimestamps:
|
Rails/CreateTableWithTimestamps:
|
||||||
|
|
|
@ -161,7 +161,7 @@ module ApplicationHelper
|
||||||
output << 'system-font' if current_account&.user&.setting_system_font_ui
|
output << 'system-font' if current_account&.user&.setting_system_font_ui
|
||||||
output << (current_account&.user&.setting_reduce_motion ? 'reduce-motion' : 'no-reduce-motion')
|
output << (current_account&.user&.setting_reduce_motion ? 'reduce-motion' : 'no-reduce-motion')
|
||||||
output << 'rtl' if locale_direction == 'rtl'
|
output << 'rtl' if locale_direction == 'rtl'
|
||||||
output.reject(&:blank?).join(' ')
|
output.compact_blank.join(' ')
|
||||||
end
|
end
|
||||||
|
|
||||||
def cdn_host
|
def cdn_host
|
||||||
|
|
|
@ -51,14 +51,14 @@ module StatusesHelper
|
||||||
end
|
end
|
||||||
|
|
||||||
def status_description(status)
|
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?
|
if status.spoiler_text.blank?
|
||||||
components << status.text
|
components << status.text
|
||||||
components << poll_summary(status)
|
components << poll_summary(status)
|
||||||
end
|
end
|
||||||
|
|
||||||
components.reject(&:blank?).join("\n\n")
|
components.compact_blank.join("\n\n")
|
||||||
end
|
end
|
||||||
|
|
||||||
def stream_link_target
|
def stream_link_target
|
||||||
|
|
|
@ -46,7 +46,7 @@ module Attachmentable
|
||||||
def set_file_extension(attachment) # rubocop:disable Naming/AccessorMethodName
|
def set_file_extension(attachment) # rubocop:disable Naming/AccessorMethodName
|
||||||
return if attachment.blank?
|
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
|
end
|
||||||
|
|
||||||
def check_image_dimension(attachment)
|
def check_image_dimension(attachment)
|
||||||
|
|
|
@ -101,7 +101,7 @@ class Poll < ApplicationRecord
|
||||||
end
|
end
|
||||||
|
|
||||||
def prepare_options
|
def prepare_options
|
||||||
self.options = options.map(&:strip).reject(&:blank?)
|
self.options = options.map(&:strip).compact_blank
|
||||||
end
|
end
|
||||||
|
|
||||||
def reset_parent_cache
|
def reset_parent_cache
|
||||||
|
|
|
@ -445,7 +445,6 @@ class User < ApplicationRecord
|
||||||
return if chosen_languages.nil?
|
return if chosen_languages.nil?
|
||||||
|
|
||||||
chosen_languages.compact_blank!
|
chosen_languages.compact_blank!
|
||||||
|
|
||||||
self.chosen_languages = nil if chosen_languages.empty?
|
self.chosen_languages = nil if chosen_languages.empty?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -132,7 +132,7 @@ class ImportService < BaseService
|
||||||
def parse_import_data!(default_headers)
|
def parse_import_data!(default_headers)
|
||||||
data = CSV.parse(import_data, headers: true)
|
data = CSV.parse(import_data, headers: true)
|
||||||
data = CSV.parse(import_data, headers: default_headers) unless data.headers&.first&.strip&.include?(' ')
|
data = CSV.parse(import_data, headers: default_headers) unless data.headers&.first&.strip&.include?(' ')
|
||||||
@data = data.reject(&:blank?)
|
@data = data.compact_blank
|
||||||
end
|
end
|
||||||
|
|
||||||
def import_data
|
def import_data
|
||||||
|
|
|
@ -7,7 +7,7 @@ Paperclip.interpolates :filename do |attachment, style|
|
||||||
if style == :original
|
if style == :original
|
||||||
attachment.original_filename
|
attachment.original_filename
|
||||||
else
|
else
|
||||||
[basename(attachment, style), extension(attachment, style)].delete_if(&:blank?).join('.')
|
[basename(attachment, style), extension(attachment, style)].compact_blank!.join('.')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue