mirror of
https://github.com/discourse/discourse.git
synced 2025-06-01 07:37:55 +08:00
DEV: Update to lastest rubocop-discourse
This commit is contained in:

committed by
Loïc Guitaut

parent
3b6d4c830f
commit
2a28cda15c
@ -1853,7 +1853,7 @@ class BulkImport::Base
|
||||
end
|
||||
|
||||
def normalize_text(text)
|
||||
return nil unless text.present?
|
||||
return nil if text.blank?
|
||||
@html_entities.decode(normalize_charset(text.presence || "").scrub)
|
||||
end
|
||||
|
||||
|
@ -910,7 +910,7 @@ class BulkImport::DiscourseMerger < BulkImport::Base
|
||||
end
|
||||
|
||||
def process_post_action(post_action)
|
||||
return nil unless post_action["post_id"].present?
|
||||
return nil if post_action["post_id"].blank?
|
||||
post_action["related_post_id"] = post_id_from_imported_id(post_action["related_post_id"])
|
||||
post_action["deferred_by_id"] = user_id_from_imported_id(post_action["deferred_by_id"])
|
||||
post_action["agreed_by_id"] = user_id_from_imported_id(post_action["agreed_by_id"])
|
||||
@ -969,7 +969,7 @@ class BulkImport::DiscourseMerger < BulkImport::Base
|
||||
end
|
||||
|
||||
def process_group_archived_message(gam)
|
||||
return nil unless gam["topic_id"].present? && gam["group_id"].present?
|
||||
return nil if gam["topic_id"].blank? || gam["group_id"].blank?
|
||||
gam
|
||||
end
|
||||
|
||||
@ -990,14 +990,12 @@ class BulkImport::DiscourseMerger < BulkImport::Base
|
||||
user_avatar["gravatar_upload_id"] = upload_id_from_imported_id(
|
||||
user_avatar["gravatar_upload_id"],
|
||||
) if user_avatar["gravatar_upload_id"]
|
||||
unless user_avatar["custom_upload_id"].present? || user_avatar["gravatar_upload_id"].present?
|
||||
return nil
|
||||
end
|
||||
return nil if user_avatar["custom_upload_id"].blank? && user_avatar["gravatar_upload_id"].blank?
|
||||
user_avatar
|
||||
end
|
||||
|
||||
def process_user_history(user_history)
|
||||
return nil unless user_history["group_id"].present?
|
||||
return nil if user_history["group_id"].blank?
|
||||
user_history["acting_user_id"] = user_id_from_imported_id(
|
||||
user_history["acting_user_id"],
|
||||
) if user_history["acting_user_id"]
|
||||
@ -1011,7 +1009,7 @@ class BulkImport::DiscourseMerger < BulkImport::Base
|
||||
user_warning["created_by_id"] = user_id_from_imported_id(
|
||||
user_warning["created_by_id"],
|
||||
) if user_warning["created_by_id"]
|
||||
return nil unless user_warning["created_by_id"].present?
|
||||
return nil if user_warning["created_by_id"].blank?
|
||||
user_warning
|
||||
end
|
||||
|
||||
|
@ -165,7 +165,7 @@ class BulkImport::Generic < BulkImport::Base
|
||||
when "append"
|
||||
raise "Cannot append to #{name} setting" if setting[:type] != "list"
|
||||
items = (SiteSetting.get(name) || "").split("|")
|
||||
items << row["value"] unless items.include?(row["value"])
|
||||
items << row["value"] if items.exclude?(row["value"])
|
||||
SiteSetting.set_and_log(name, items.join("|"))
|
||||
end
|
||||
end
|
||||
@ -2287,7 +2287,7 @@ class BulkImport::Generic < BulkImport::Base
|
||||
|
||||
rows.each do |row|
|
||||
normalization = row["normalization"]
|
||||
normalizations << normalization unless normalizations.include?(normalization)
|
||||
normalizations << normalization if normalizations.exclude?(normalization)
|
||||
end
|
||||
|
||||
SiteSetting.permalink_normalizations = normalizations.join("|")
|
||||
|
@ -114,7 +114,7 @@ module BulkImport
|
||||
producer_thread =
|
||||
Thread.new do
|
||||
query("SELECT * FROM uploads ORDER BY id", @source_db).tap do |result_set|
|
||||
result_set.each { |row| queue << row unless output_existing_ids.include?(row["id"]) }
|
||||
result_set.each { |row| queue << row if output_existing_ids.exclude?(row["id"]) }
|
||||
result_set.close
|
||||
end
|
||||
end
|
||||
@ -612,7 +612,7 @@ module BulkImport
|
||||
begin
|
||||
if optimized_images.present?
|
||||
optimized_images.map! do |optimized_image|
|
||||
next unless optimized_image.present?
|
||||
next if optimized_image.blank?
|
||||
optimized_image_path =
|
||||
add_multisite_prefix(store.get_path_for_optimized_image(optimized_image))
|
||||
|
||||
|
@ -227,7 +227,7 @@ class BulkImport::Vanilla < BulkImport::Base
|
||||
).first
|
||||
next if r.nil?
|
||||
photo = r["photo"]
|
||||
next unless photo.present?
|
||||
next if photo.blank?
|
||||
|
||||
# Possible encoded values:
|
||||
# 1. cf://uploads/userpics/820/Y0AFUQYYM6QN.jpg
|
||||
@ -305,7 +305,7 @@ class BulkImport::Vanilla < BulkImport::Base
|
||||
next if r.nil?
|
||||
path = r["Path"]
|
||||
name = r["Name"]
|
||||
next unless path.present?
|
||||
next if path.blank?
|
||||
|
||||
path.gsub!("s3://content/", "")
|
||||
path.gsub!("s3://uploads/", "")
|
||||
|
@ -640,9 +640,9 @@ class BulkImport::VBulletin < BulkImport::Base
|
||||
next if item == (".") || item == ("..") || item == (".DS_Store")
|
||||
next unless item =~ /avatar(\d+)_(\d).gif/
|
||||
scan = item.scan(/avatar(\d+)_(\d).gif/)
|
||||
next unless scan[0][0].present?
|
||||
next if scan[0][0].blank?
|
||||
u = UserCustomField.find_by(name: "import_id", value: scan[0][0]).try(:user)
|
||||
next unless u.present?
|
||||
next if u.blank?
|
||||
# raise "User not found for id #{user_id}" if user.blank?
|
||||
|
||||
photo_real_filename = File.join(AVATAR_DIR, item)
|
||||
@ -686,10 +686,10 @@ class BulkImport::VBulletin < BulkImport::Base
|
||||
print_status current_count, total_count
|
||||
user_id = sig[0]
|
||||
user_sig = sig[1]
|
||||
next unless user_id.present? && user_sig.present?
|
||||
next if user_id.blank? || user_sig.blank?
|
||||
|
||||
u = UserCustomField.find_by(name: "import_id", value: user_id).try(:user)
|
||||
next unless u.present?
|
||||
next if u.blank?
|
||||
|
||||
# can not hold dupes
|
||||
UserCustomField.where(
|
||||
|
Reference in New Issue
Block a user