DEV: update rubocop to version 0.77

We like to stay as close as possible to latest with rubocop cause the cops
get better.

This update required some code changes, specifically the default is to avoid
explicit returns where implicit is done

Also this renames a few rules
This commit is contained in:
Sam Saffron
2019-12-10 11:48:27 +11:00
parent 8e489ec8f8
commit 0c52537f10
23 changed files with 39 additions and 39 deletions

View File

@ -222,7 +222,7 @@ class ImportScripts::Base
if existing == import_ids.length
puts "Skipping #{import_ids.length} already imported #{type}"
return true
true
end
ensure
connection.exec('DROP TABLE import_ids') unless connection.nil?

View File

@ -833,9 +833,9 @@ class ImportScripts::DiscuzX < ImportScripts::Base
file_name = "#{part_4}_avatar_big.jpg"
if absolute
return File.join(DISCUZX_BASE_DIR, AVATAR_DIR, part_1, part_2, part_3, file_name), file_name
[File.join(DISCUZX_BASE_DIR, AVATAR_DIR, part_1, part_2, part_3, file_name), file_name]
else
return File.join(AVATAR_DIR, part_1, part_2, part_3, file_name), file_name
[File.join(AVATAR_DIR, part_1, part_2, part_3, file_name), file_name]
end
end

View File

@ -573,7 +573,7 @@ class ImportScripts::FMGP < ImportScripts::Base
# Also deal with 0x80 (really‽) and non-breaking spaces
text = fragment[1].gsub(/(\u200d|\u0080)/, "").gsub(/\u00a0/, " ")
if fragment[2].nil?
return text
text
else
if fragment[2]["italic"].present?
text = "<i>#{text}</i>"
@ -585,7 +585,7 @@ class ImportScripts::FMGP < ImportScripts::Base
# s more likely than del to represent user intent?
text = "<s>#{text}</s>"
end
return text
text
end
elsif fragment[0] == 1
"\n"
@ -604,17 +604,17 @@ class ImportScripts::FMGP < ImportScripts::Base
# G+ occasionally doesn't put proper spaces after users
if user = find_user_by_import_id(fragment[2])
# user was in this import's authors
return "@#{user.username} "
"@#{user.username} "
else
if google_user_info = UserAssociatedAccount.find_by(provider_name: 'google_oauth2', provider_uid: fragment[2])
# user was not in this import, but has logged in or been imported otherwise
user = User.find(google_user_info.user_id)
return "@#{user.username} "
"@#{user.username} "
else
raise RuntimeError.new("Google user #{fragment[1]} (id #{fragment[2]}) not imported") if !@dryrun
# if you want to fall back to their G+ name, just erase the raise above,
# but this should not happen
return "<b>+#{fragment[1]}</b>"
"<b>+#{fragment[1]}</b>"
end
end
elsif fragment[0] == 4
@ -669,14 +669,14 @@ class ImportScripts::FMGP < ImportScripts::Base
end
if text == url
# leave the URL bare and Discourse will do the right thing
return url
url
else
# It turns out that the only place we get here, google has done its own text
# interpolation that doesn't look good on Discourse, so while it looks like
# this should be:
# return "[#{text}](#{url})"
# it actually looks better to throw away the google-provided text:
return url
url
end
end
end

View File

@ -190,14 +190,14 @@ class ImportScripts::MyBB < ImportScripts::Base
if quoted_post_id_from_imported
begin
post = Post.find(quoted_post_id_from_imported)
return "post:#{post.post_number}, topic:#{post.topic_id}"
"post:#{post.post_number}, topic:#{post.topic_id}"
rescue
puts "Could not find migrated post #{quoted_post_id_from_imported} quoted by original post #{post_id} as #{quoted_post_id}"
return ""
""
end
else
puts "Original post #{post_id} quotes nonexistent post #{quoted_post_id}"
return ""
""
end
end

View File

@ -19,7 +19,7 @@ class ImportScripts::Ning < ImportScripts::Base
@discussions_json = load_ning_json("ning-discussions-local.json")
# An example of a custom category from Ning:
@blogs_json = load_ning_json("ning-blogs-local.json")
@blogs_json = load_ning_json("ning-blogs-local.json")
@photos_json = load_ning_json("ning-photos-local.json")
@pages_json = load_ning_json("ning-pages-local.json")