DEV: Enable unless cops

We discussed the use of `unless` internally and decided to enforce
available rules from rubocop to restrict its most problematic uses.
This commit is contained in:
Loïc Guitaut
2023-02-16 10:40:11 +01:00
committed by Loïc Guitaut
parent 87de3c2319
commit f7c57fbc19
56 changed files with 137 additions and 142 deletions

View File

@ -335,7 +335,15 @@ class ImportScripts::XenForo < ImportScripts::Base
created_at: Time.zone.at(post["message_date"].to_i),
import_mode: true,
}
unless post["topic_id"] > 0
if post["topic_id"] <= 0
topic_id = post["topic_id"]
if t = topic_lookup_from_imported_post_id("pm_#{topic_id}")
msg[:topic_id] = t[:topic_id]
else
puts "Topic ID #{topic_id} not found, skipping post #{post["message_id"]} from #{post["user_id"]}"
next
end
else
msg[:title] = post["title"]
msg[:archetype] = Archetype.private_message
to_user_array = PHP.unserialize(post["recipients"])
@ -344,14 +352,6 @@ class ImportScripts::XenForo < ImportScripts::Base
usernames = User.where(id: [discourse_user_ids]).pluck(:username)
msg[:target_usernames] = usernames.join(",")
end
else
topic_id = post["topic_id"]
if t = topic_lookup_from_imported_post_id("pm_#{topic_id}")
msg[:topic_id] = t[:topic_id]
else
puts "Topic ID #{topic_id} not found, skipping post #{post["message_id"]} from #{post["user_id"]}"
next
end
end
msg
else