DEV: Update to lastest rubocop-discourse

This commit is contained in:
Loïc Guitaut
2024-05-27 18:06:14 +02:00
committed by Loïc Guitaut
parent c4c3e8d40e
commit db1c19d472
164 changed files with 269 additions and 263 deletions
+1 -1
View File
@@ -318,7 +318,7 @@ class ImportScripts::Answerbase < ImportScripts::Base
end
def add_normalization(normalizations, normalization)
normalizations << normalization unless normalizations.include?(normalization)
normalizations << normalization if normalizations.exclude?(normalization)
end
def permalink_exists?(url)
+1 -1
View File
@@ -155,7 +155,7 @@ class ImportScripts::MyAskBot < ImportScripts::Base
cat = nil
if tags
CATEGORIES.each do |cname|
next unless tags.include?(cname.downcase)
next if tags.exclude?(cname.downcase)
cat = cname
break
end
+1 -1
View File
@@ -994,7 +994,7 @@ class ImportScripts::DiscuzX < ImportScripts::Base
next
end
html = html_for_upload(upload, filename)
unless new_raw.include? html
if new_raw.exclude? html
new_raw << "\n"
new_raw << html
end
+1 -1
View File
@@ -73,7 +73,7 @@ class ImportScripts::Disqus < ImportScripts::Base
if post.present? && post.topic.posts_count <= 1
(t[:posts] || []).each do |p|
post_user = find_existing_user(p[:author_email] || "", p[:author_username])
next unless post_user.present?
next if post_user.blank?
attrs = {
user_id: post_user.id,
+1 -1
View File
@@ -383,7 +383,7 @@ class ImportScripts::Drupal < ImportScripts::Base
end
upload_html = html_for_upload(upload, filename)
new_raw = "#{new_raw}\n\n#{upload_html}" unless new_raw.include?(upload_html)
new_raw = "#{new_raw}\n\n#{upload_html}" if new_raw.exclude?(upload_html)
if new_raw != post.raw
PostRevisor.new(post).revise!(
+3 -3
View File
@@ -188,7 +188,7 @@ class ImportScripts::Jive < ImportScripts::Base
rows = []
csv_parse("communities") do |row|
next unless CATEGORY_IDS.include?(row.communityid.to_i)
next if CATEGORY_IDS.exclude?(row.communityid.to_i)
rows << { id: row.communityid, name: "#{row.name} (#{row.communityid})" }
end
@@ -261,7 +261,7 @@ class ImportScripts::Jive < ImportScripts::Base
thread_map = {}
csv_parse("messages") do |thread|
next unless CATEGORY_IDS.include?(thread.containerid.to_i)
next if CATEGORY_IDS.exclude?(thread.containerid.to_i)
if !thread.parentmessageid
# topic
@@ -329,7 +329,7 @@ class ImportScripts::Jive < ImportScripts::Base
csv_parse("messages") do |thread|
# post
next unless CATEGORY_IDS.include?(thread.containerid.to_i)
next if CATEGORY_IDS.exclude?(thread.containerid.to_i)
if thread.parentmessageid
#IMAGE UPLOADER
+1 -1
View File
@@ -75,7 +75,7 @@ class ImportScripts::Kunena < ImportScripts::Base
results =
@client.query("SELECT id, username, email, registerDate FROM jos_users;", cache_rows: false)
results.each do |u|
next unless u["id"].to_i > (0) && u["username"].present? && u["email"].present?
next if u["id"].to_i <= (0) || u["username"].blank? || u["email"].blank?
username = u["username"].gsub(" ", "_").gsub(/[^A-Za-z0-9_]/, "")[0, User.username_length.end]
if username.length < User.username_length.first
username = username * User.username_length.first
+1 -1
View File
@@ -94,7 +94,7 @@ class ImportScripts::Kunena < ImportScripts::Base
cache_rows: false,
)
results.each do |u|
next unless u["id"].to_i > (0) && u["username"].present? && u["email"].present?
next if u["id"].to_i <= (0) || u["username"].blank? || u["email"].blank?
username = u["username"].gsub(" ", "_").gsub(/[^A-Za-z0-9_]/, "")[0, User.username_length.end]
if username.length < User.username_length.first
username = username * User.username_length.first
@@ -218,7 +218,7 @@ module ImportScripts::Mbox
end
def read_mail_from_string(raw_message)
unless raw_message.blank?
if raw_message.present?
Email::Receiver.new(raw_message, convert_plaintext: true, skip_trimming: false)
end
end
+2 -2
View File
@@ -224,7 +224,7 @@ class ImportScripts::MylittleforumSQL < ImportScripts::Base
raw = clean_up(discussion["Body"])
youtube = nil
unless discussion["youtube"].blank?
if discussion["youtube"].present?
youtube = clean_youtube(discussion["youtube"])
raw += "\n#{youtube}\n"
print_warning(raw)
@@ -286,7 +286,7 @@ class ImportScripts::MylittleforumSQL < ImportScripts::Base
next if comment["Body"].blank?
raw = clean_up(comment["Body"])
youtube = nil
unless comment["youtube"].blank?
if comment["youtube"].present?
youtube = clean_youtube(comment["youtube"])
raw += "\n#{youtube}\n"
end
@@ -136,7 +136,7 @@ module ImportScripts::PhpBB3
# This appears to be a reply. Let's try to find the Discourse topic_id for this message.
parent_msg_id = get_import_id(row[:root_msg_id])
parent = @lookup.topic_lookup_from_imported_post_id(parent_msg_id)
parent[:topic_id] unless parent.blank?
parent[:topic_id] if parent.present?
end
end
@@ -56,7 +56,7 @@ module ImportScripts::PhpBB3
normalization = "/#{prefix.gsub("/", '\/')}\\#{normalization}"
end
normalizations << normalization unless normalizations.include?(normalization)
normalizations << normalization if normalizations.exclude?(normalization)
end
def permalink_exists(url)
+1 -1
View File
@@ -38,7 +38,7 @@ class ImportScripts::Sfn < ImportScripts::Base
@external_users = {}
CSV.foreach("/Users/zogstrip/Desktop/sfn.csv", col_sep: ";") do |row|
next unless @personify_id_to_contact_key.include?(row[0])
next if @personify_id_to_contact_key.exclude?(row[0])
id = @personify_id_to_contact_key[row[0]]
full_name = [row[1].strip, row[2].strip, row[3].strip].join(" ").strip
+2 -2
View File
@@ -278,7 +278,7 @@ class ImportScripts::Smf2 < ImportScripts::Base
attachment[:file_hash],
attachment[:filename],
)
raise "Attachment for post #{post[:id]} failed: #{attachment[:filename]}" unless path.present?
raise "Attachment for post #{post[:id]} failed: #{attachment[:filename]}" if path.blank?
upload = create_upload(post[:user_id], path, attachment[:filename])
unless upload.persisted?
raise "Attachment for post #{post[:id]} failed: #{upload.errors.full_messages.join(", ")}"
@@ -378,7 +378,7 @@ class ImportScripts::Smf2 < ImportScripts::Base
pattern, emitter = *p
body.gsub!(pattern) do |s|
next s if (num = $~[:num].to_i - 1) < 0
next s unless (upload = attachments[num]).present?
next s if (upload = attachments[num]).blank?
use_count[num] += 1
instance_exec(upload, &emitter)
end
+1 -1
View File
@@ -888,7 +888,7 @@ class ImportScripts::Telligent < ImportScripts::Base
end
def add_normalization(normalizations, normalization)
normalizations << normalization unless normalizations.include?(normalization)
normalizations << normalization if normalizations.exclude?(normalization)
end
def batches
+2 -2
View File
@@ -166,7 +166,7 @@ class ImportScripts::VanillaSQL < ImportScripts::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
@@ -642,7 +642,7 @@ class ImportScripts::VanillaSQL < ImportScripts::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/", "")
+6 -6
View File
@@ -107,7 +107,7 @@ class ImportScripts::Yammer < ImportScripts::Base
csv_parse("Messages") do |row|
next unless row[:thread_id] == row[:id]
next if row[:in_private_conversation] == "true"
next unless row[:deleted_at].blank?
next if row[:deleted_at].present?
# next if row[:message_type] == 'system'
title = ""
url = ""
@@ -119,7 +119,7 @@ class ImportScripts::Yammer < ImportScripts::Base
url = Regexp.last_match(2)
title = Regexp.last_match(3) if Regexp.last_match(3)
description = Regexp.last_match(4)
raw += "\n***\n#{description}\n#{url}\n" unless raw.include?(url)
raw += "\n***\n#{description}\n#{url}\n" if raw.exclude?(url)
end
row[:attachments].match(/uploadedfile:(\d*)$/) do
file_id = Regexp.last_match(1).to_i
@@ -148,7 +148,7 @@ class ImportScripts::Yammer < ImportScripts::Base
csv_parse("Messages") do |row|
next unless row[:thread_id] == row[:id]
next unless row[:in_private_conversation] == "true"
next unless row[:deleted_at].blank?
next if row[:deleted_at].present?
# next if row[:message_type] == 'system'
title = ""
url = ""
@@ -160,7 +160,7 @@ class ImportScripts::Yammer < ImportScripts::Base
url = Regexp.last_match(2)
title = Regexp.last_match(3) if Regexp.last_match(3)
description = Regexp.last_match(4)
raw += "\n***\n#{description}\n#{url}\n" unless raw.include?(url)
raw += "\n***\n#{description}\n#{url}\n" if raw.exclude?(url)
end
row[:attachments].match(/uploadedfile:(\d*)$/) do
file_id = Regexp.last_match(1).to_i
@@ -189,7 +189,7 @@ class ImportScripts::Yammer < ImportScripts::Base
# get posts from messages
csv_parse("Messages") do |row|
next if row[:thread_id] == row[:id]
next unless row[:deleted_at].blank?
next if row[:deleted_at].present?
next if row[:in_private_conversation] == "true"
@db.insert_post(
id: row[:id],
@@ -204,7 +204,7 @@ class ImportScripts::Yammer < ImportScripts::Base
# get pm posts from messages
csv_parse("Messages") do |row|
next if row[:thread_id] == row[:id]
next unless row[:deleted_at].blank?
next if row[:deleted_at].present?
next unless row[:in_private_conversation] == "false"
@db.insert_pm_post(
id: row[:id],
+1 -1
View File
@@ -79,7 +79,7 @@ class ImportScripts::Zoho < ImportScripts::Base
@all_posts << row.dup
@categories[row.forum_name] = [] if @categories[row.forum_name].nil?
unless @categories[row.forum_name].include?(row.category_name)
if @categories[row.forum_name].exclude?(row.category_name)
@categories[row.forum_name] << row.category_name
end
end