diff --git a/.rubocop.yml b/.rubocop.yml index eebd794151e..2c2c5fd9f93 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -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: diff --git a/Gemfile.lock b/Gemfile.lock index fdd2b342da6..d04e74ec4ca 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -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) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 48ce0506c94..bd8239d85b2 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -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 diff --git a/app/controllers/categories_controller.rb b/app/controllers/categories_controller.rb index 191b2f433e2..c8a6a1f0e0b 100644 --- a/app/controllers/categories_controller.rb +++ b/app/controllers/categories_controller.rb @@ -142,7 +142,7 @@ class CategoriesController < ApplicationController render_serialized(@category, CategorySerializer) else - return render_json_error(@category) + render_json_error(@category) end end diff --git a/app/controllers/finish_installation_controller.rb b/app/controllers/finish_installation_controller.rb index 580047adc44..13b7b64f5df 100644 --- a/app/controllers/finish_installation_controller.rb +++ b/app/controllers/finish_installation_controller.rb @@ -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 diff --git a/app/controllers/reviewables_controller.rb b/app/controllers/reviewables_controller.rb index ce5c2cd29e4..506eb8f9e98 100644 --- a/app/controllers/reviewables_controller.rb +++ b/app/controllers/reviewables_controller.rb @@ -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 diff --git a/app/controllers/session_controller.rb b/app/controllers/session_controller.rb index a0828685a7f..b0687625209 100644 --- a/app/controllers/session_controller.rb +++ b/app/controllers/session_controller.rb @@ -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 diff --git a/app/controllers/users/omniauth_callbacks_controller.rb b/app/controllers/users/omniauth_callbacks_controller.rb index 5e383872240..1984932057a 100644 --- a/app/controllers/users/omniauth_callbacks_controller.rb +++ b/app/controllers/users/omniauth_callbacks_controller.rb @@ -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 diff --git a/app/jobs/regular/user_email.rb b/app/jobs/regular/user_email.rb index dcc0059d9f6..afa1105e4fc 100644 --- a/app/jobs/regular/user_email.rb +++ b/app/jobs/regular/user_email.rb @@ -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 diff --git a/app/models/color_scheme.rb b/app/models/color_scheme.rb index 0e6f7f7b23e..9c50aa716e9 100644 --- a/app/models/color_scheme.rb +++ b/app/models/color_scheme.rb @@ -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' diff --git a/app/models/translation_override.rb b/app/models/translation_override.rb index bef0c3eb1df..8d1f31cc43b 100644 --- a/app/models/translation_override.rb +++ b/app/models/translation_override.rb @@ -94,7 +94,7 @@ class TranslationOverride < ActiveRecord::Base keys: invalid_keys.join(', ') )) - return false + false end end end diff --git a/app/services/user_silencer.rb b/app/services/user_silencer.rb index 6dd2edf736b..9f192dc6f67 100644 --- a/app/services/user_silencer.rb +++ b/app/services/user_silencer.rb @@ -59,7 +59,7 @@ class UserSilencer silenced_till: @user.silenced_till, silenced_at: DateTime.now ) - return true + true end else false diff --git a/db/migrate/20141216112341_resolve_duplicate_group_names.rb b/db/migrate/20141216112341_resolve_duplicate_group_names.rb index b6072e78cd3..c9249af68b7 100644 --- a/db/migrate/20141216112341_resolve_duplicate_group_names.rb +++ b/db/migrate/20141216112341_resolve_duplicate_group_names.rb @@ -10,7 +10,7 @@ class ResolveDuplicateGroupNames < ActiveRecord::Migration[4.2] GROUP BY lower(name) HAVING count(*) > 1);' - groups = Group.where id: results + groups = Group.where id: results groups.group_by { |g| g.name.downcase }.each do |key, value| value.each_with_index do |dup, index| dup.update! name: "#{dup.name[0..18]}_#{index + 1}" if index > 0 diff --git a/lib/email/receiver.rb b/lib/email/receiver.rb index 06b2700cdfb..1f41e4b66e4 100644 --- a/lib/email/receiver.rb +++ b/lib/email/receiver.rb @@ -934,7 +934,7 @@ module Email return if message_ids.empty? host = Email::Sender.host_for(Discourse.base_url) - post_id_regexp = Regexp.new "topic/\\d+/(\\d+)@#{Regexp.escape(host)}" + post_id_regexp = Regexp.new "topic/\\d+/(\\d+)@#{Regexp.escape(host)}" topic_id_regexp = Regexp.new "topic/(\\d+)@#{Regexp.escape(host)}" post_ids = message_ids.map { |message_id| message_id[post_id_regexp, 1] }.compact.map(&:to_i) diff --git a/script/bulk_import/base.rb b/script/bulk_import/base.rb index b72104e31c7..8af89155e1c 100644 --- a/script/bulk_import/base.rb +++ b/script/bulk_import/base.rb @@ -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" diff --git a/script/import_scripts/base.rb b/script/import_scripts/base.rb index 1959566c174..80214da26a2 100644 --- a/script/import_scripts/base.rb +++ b/script/import_scripts/base.rb @@ -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? diff --git a/script/import_scripts/discuz_x.rb b/script/import_scripts/discuz_x.rb index 9aed7a7cc0c..7b4679981f8 100644 --- a/script/import_scripts/discuz_x.rb +++ b/script/import_scripts/discuz_x.rb @@ -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 diff --git a/script/import_scripts/friendsmegplus.rb b/script/import_scripts/friendsmegplus.rb index cd9c045c3b8..3eb76239515 100644 --- a/script/import_scripts/friendsmegplus.rb +++ b/script/import_scripts/friendsmegplus.rb @@ -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 = "#{text}" @@ -585,7 +585,7 @@ class ImportScripts::FMGP < ImportScripts::Base # s more likely than del to represent user intent? text = "#{text}" 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 "+#{fragment[1]}" + "+#{fragment[1]}" 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 diff --git a/script/import_scripts/mybb.rb b/script/import_scripts/mybb.rb index 259e855c377..0b78cf0f7a3 100644 --- a/script/import_scripts/mybb.rb +++ b/script/import_scripts/mybb.rb @@ -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 diff --git a/script/import_scripts/ning.rb b/script/import_scripts/ning.rb index e5e7ed8dce0..712f07b8617 100644 --- a/script/import_scripts/ning.rb +++ b/script/import_scripts/ning.rb @@ -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") diff --git a/spec/models/color_scheme_spec.rb b/spec/models/color_scheme_spec.rb index 7fa3aa679d9..4a9f34018b4 100644 --- a/spec/models/color_scheme_spec.rb +++ b/spec/models/color_scheme_spec.rb @@ -54,7 +54,7 @@ describe ColorScheme do it "creates a new color scheme" do c = described_class.create_from_base(name: 'Yellow', colors: { first_one: 'FFFF00', third_one: 'F00D33' }) expect(c.colors.size).to eq base_colors.size - first = c.colors.find { |x| x.name == 'first_one' } + first = c.colors.find { |x| x.name == 'first_one' } second = c.colors.find { |x| x.name == 'second_one' } third = c.colors.find { |x| x.name == 'third_one' } expect(first.hex).to eq 'FFFF00' diff --git a/spec/models/trust_level3_requirements_spec.rb b/spec/models/trust_level3_requirements_spec.rb index b027d1e5410..bf48291c396 100644 --- a/spec/models/trust_level3_requirements_spec.rb +++ b/spec/models/trust_level3_requirements_spec.rb @@ -204,7 +204,7 @@ describe TrustLevel3Requirements do _not_a_reply = create_post(user: user) # user created the topic, so it doesn't count topic1 = create_post.topic - _reply1 = create_post(topic: topic1, user: user) + _reply1 = create_post(topic: topic1, user: user) _reply_again = create_post(topic: topic1, user: user) # two replies in one topic topic2 = create_post(created_at: 101.days.ago).topic @@ -319,7 +319,7 @@ describe TrustLevel3Requirements do UserActionManager.enable t = Fabricate(:topic, user: user, created_at: 102.days.ago) - old_post = create_post(topic: t, user: user, created_at: 102.days.ago) + old_post = create_post(topic: t, user: user, created_at: 102.days.ago) recent_post2 = create_post(topic: t, user: user, created_at: 10.days.ago) recent_post1 = create_post(topic: t, user: user, created_at: 1.hour.ago) diff --git a/spec/support/concurrency.rb b/spec/support/concurrency.rb index fdc0f796ccd..5d3cd0c87c4 100644 --- a/spec/support/concurrency.rb +++ b/spec/support/concurrency.rb @@ -219,7 +219,7 @@ module Concurrency previous_value, @in_transaction = @in_transaction, true begin - return yield + yield ensure @in_transaction = previous_value end