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

@ -86,7 +86,7 @@ Layout/Tab:
Enabled: true
# Blank lines should not have any spaces.
Layout/TrailingBlankLines:
Layout/TrailingEmptyLines:
Enabled: true
# No trailing whitespace.
@ -116,7 +116,7 @@ Layout/MultilineMethodCallIndentation:
Enabled: true
EnforcedStyle: indented
Layout/AlignHash:
Layout/HashAlignment:
Enabled: true
Bundler/OrderedGems:

View File

@ -150,7 +150,7 @@ GEM
concurrent-ruby (~> 1.0)
image_size (1.5.0)
in_threads (1.5.1)
jaro_winkler (1.5.2)
jaro_winkler (1.5.4)
jmespath (1.4.0)
jquery-rails (4.3.3)
rails-dom-testing (>= 1, < 3)
@ -257,7 +257,7 @@ GEM
parallel (1.19.1)
parallel_tests (2.29.2)
parallel
parser (2.6.3.0)
parser (2.6.5.0)
ast (~> 2.4.0)
pg (1.1.4)
progress (3.5.0)
@ -344,7 +344,7 @@ GEM
rspec-support (~> 3.8)
rspec-support (3.9.0)
rtlit (0.0.5)
rubocop (0.69.0)
rubocop (0.77.0)
jaro_winkler (~> 1.5.1)
parallel (~> 1.10)
parser (>= 2.6)
@ -355,7 +355,7 @@ GEM
rubocop (>= 0.69.0)
ruby-openid (2.9.2)
ruby-prof (1.0.0)
ruby-progressbar (1.10.0)
ruby-progressbar (1.10.1)
ruby-readability (0.7.0)
guess_html_encoding (>= 0.0.4)
nokogiri (>= 1.6.0)

View File

@ -757,7 +757,7 @@ class ApplicationController < ActionController::Base
redirect_path = "#{GlobalSetting.relative_url_root}/u/#{current_user.username}/preferences/second-factor"
if !request.fullpath.start_with?(redirect_path)
redirect_to path(redirect_path)
return
nil
end
end
end

View File

@ -142,7 +142,7 @@ class CategoriesController < ApplicationController
render_serialized(@category, CategorySerializer)
else
return render_json_error(@category)
render_json_error(@category)
end
end

View File

@ -31,7 +31,7 @@ class FinishInstallationController < ApplicationController
if @user.save
@user.change_trust_level!(1) if @user.trust_level < 1
send_signup_email
return redirect_confirm(@user.email)
redirect_confirm(@user.email)
end
end

View File

@ -169,7 +169,7 @@ class ReviewablesController < ApplicationController
render_json_error(reviewable.errors)
end
rescue Reviewable::UpdateConflict
return render_json_error(I18n.t('reviewables.conflict'), status: 409)
render_json_error(I18n.t('reviewables.conflict'), status: 409)
end
end

View File

@ -492,7 +492,7 @@ class SessionController < ApplicationController
end
if ScreenedIpAddress.block_admin_login?(user, request.remote_ip)
return admin_not_allowed_from_ip_address(user)
admin_not_allowed_from_ip_address(user)
end
end

View File

@ -67,7 +67,7 @@ class Users::OmniauthCallbacksController < ApplicationController
if @auth_result.failed?
flash[:error] = @auth_result.failed_reason.html_safe
return render('failure')
render('failure')
else
@auth_result.authenticator_name = authenticator.name
complete_response_data

View File

@ -225,7 +225,7 @@ module Jobs
already_read = user.user_option.email_level != UserOption.email_level_types[:always] && PostTiming.exists?(topic_id: post.topic_id, post_number: post.post_number, user_id: user.id)
if already_read
return SkippedEmailLog.reason_types[:user_email_already_read]
SkippedEmailLog.reason_types[:user_email_already_read]
end
else
false

View File

@ -2,7 +2,7 @@
class ColorScheme < ActiveRecord::Base
# rubocop:disable Layout/AlignHash
# rubocop:disable Layout/HashAlignment
CUSTOM_SCHEMES = {
'Dark': {
@ -97,7 +97,7 @@ class ColorScheme < ActiveRecord::Base
}
}
# rubocop:enable Layout/AlignHash
# rubocop:enable Layout/HashAlignment
LIGHT_THEME_ID = 'Light'

View File

@ -94,7 +94,7 @@ class TranslationOverride < ActiveRecord::Base
keys: invalid_keys.join(', ')
))
return false
false
end
end
end

View File

@ -59,7 +59,7 @@ class UserSilencer
silenced_till: @user.silenced_till,
silenced_at: DateTime.now
)
return true
true
end
else
false

View File

@ -29,7 +29,7 @@ class BulkImport::Base
NOW ||= "now()".freeze
PRIVATE_OFFSET ||= 2**30
# rubocop:disable Layout/AlignHash
# rubocop:disable Layout/HashAlignment
CHARSET_MAP = {
"armscii8" => nil,
@ -70,7 +70,7 @@ class BulkImport::Base
"utf8" => Encoding::UTF_8,
}
# rubocop:enable Layout/AlignHash
# rubocop:enable Layout/HashAlignment
def initialize
charset = ENV["DB_CHARSET"] || "utf8"

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

@ -219,7 +219,7 @@ module Concurrency
previous_value, @in_transaction = @in_transaction, true
begin
return yield
yield
ensure
@in_transaction = previous_value
end