Enable Lint/ShadowingOuterLocalVariable for Rubocop.

This commit is contained in:
Guo Xiang Tan
2018-09-04 10:16:21 +08:00
parent 2f5c21e28c
commit 8dc1463ab3
16 changed files with 70 additions and 59 deletions

View File

@ -393,12 +393,12 @@ class ImportScripts::DiscuzX < ImportScripts::Base
end
if m['status'] & 1 == 1 || mapped[:raw].blank?
mapped[:post_create_action] = lambda do |post|
PostDestroyer.new(Discourse.system_user, post).perform_delete
mapped[:post_create_action] = lambda do |action_post|
PostDestroyer.new(Discourse.system_user, action_post).perform_delete
end
elsif (m['status'] & 2) >> 1 == 1 # waiting for approve
mapped[:post_create_action] = lambda do |post|
PostAction.act(Discourse.system_user, post, 6, take_action: false)
mapped[:post_create_action] = lambda do |action_post|
PostAction.act(Discourse.system_user, action_post, 6, take_action: false)
end
end
skip ? nil : mapped

View File

@ -355,10 +355,10 @@ class ImportScripts::Smf1 < ImportScripts::Base
post[:archetype] = Archetype.private_message
post[:title] = title
post[:target_usernames] = User.where(id: recipients).pluck(:username)
post[:post_create_action] = proc do |p|
post[:post_create_action] = proc do |action_post|
@pm_mapping[users] ||= {}
@pm_mapping[users][title] ||= []
@pm_mapping[users][title] << p.topic_id
@pm_mapping[users][title] << action_post.topic_id
end
end

View File

@ -201,15 +201,17 @@ class ImportScripts::Smf2 < ImportScripts::Base
SQL
skip = false
ignore_quotes = false
post = {
id: message[:id_msg],
user_id: user_id_from_imported_user_id(message[:id_member]) || -1,
created_at: Time.zone.at(message[:poster_time]),
post_create_action: ignore_quotes && proc do |post|
post.custom_fields['import_rebake'] = 't'
post.save
post_create_action: ignore_quotes && proc do |p|
p.custom_fields['import_rebake'] = 't'
p.save
end
}
if message[:id_msg] == message[:id_first_msg]
post[:category] = category_id_from_imported_category_id(message[:id_board])
post[:title] = decode_entities(message[:subject])

View File

@ -273,8 +273,8 @@ class ImportScripts::Telligent < ImportScripts::Base
user_id: user_id,
created_at: row["DateCreated"],
closed: row["IsLocked"],
post_create_action: proc do |post|
topic = post.topic
post_create_action: proc do |action_post|
topic = action_post.topic
Jobs.enqueue_at(topic.pinned_until, :unpin_topic, topic_id: topic.id) if topic.pinned_until
url = "f/#{row['ForumId']}/t/#{row['ThreadId']}"
Permalink.create(url: url, topic_id: topic.id) unless Permalink.exists?(url: url)