From: Tom Hughes Date: Tue, 1 Nov 2022 18:33:22 +0000 (+0000) Subject: Fix new rubocop warnings X-Git-Tag: live~1432 X-Git-Url: https://git.openstreetmap.org./rails.git/commitdiff_plain/49cde0e9013848d2d3bd33f19fe106296505b6b2 Fix new rubocop warnings --- diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 5303fb051..adc5d8fc8 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by # `rubocop --auto-gen-config` -# on 2022-10-25 17:25:58 UTC using RuboCop version 1.37.1. +# on 2022-11-01 18:20:38 UTC using RuboCop version 1.38.0. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new @@ -46,7 +46,7 @@ Lint/AssignmentInCondition: Metrics/AbcSize: Max: 189 -# Offense count: 72 +# Offense count: 73 # Configuration parameters: CountComments, CountAsOne, ExcludedMethods, AllowedMethods, AllowedPatterns, IgnoredMethods. # AllowedMethods: refine Metrics/BlockLength: @@ -82,7 +82,12 @@ Metrics/ParameterLists: Metrics/PerceivedComplexity: Max: 26 -# Offense count: 559 +# Offense count: 2495 +# This cop supports safe autocorrection (--autocorrect). +Minitest/EmptyLineBeforeAssertionMethods: + Enabled: false + +# Offense count: 560 Minitest/MultipleAssertions: Max: 52 @@ -96,6 +101,38 @@ Naming/PredicateName: Exclude: - 'app/models/user.rb' +# Offense count: 8 +# This cop supports unsafe autocorrection (--autocorrect-all). +Rails/ActionControllerFlashBeforeRender: + Exclude: + - 'app/controllers/confirmations_controller.rb' + - 'app/controllers/friendships_controller.rb' + - 'app/controllers/oauth_controller.rb' + - 'app/controllers/traces_controller.rb' + - 'app/controllers/user_blocks_controller.rb' + - 'app/controllers/users_controller.rb' + +# Offense count: 18 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: ExpectedOrder, Include. +# ExpectedOrder: index, show, new, edit, create, update, destroy +# Include: app/controllers/**/*.rb +Rails/ActionOrder: + Exclude: + - 'app/controllers/api/changesets_controller.rb' + - 'app/controllers/api/nodes_controller.rb' + - 'app/controllers/api/notes_controller.rb' + - 'app/controllers/api/relations_controller.rb' + - 'app/controllers/api/traces_controller.rb' + - 'app/controllers/api/users_controller.rb' + - 'app/controllers/api/ways_controller.rb' + - 'app/controllers/diary_entries_controller.rb' + - 'app/controllers/messages_controller.rb' + - 'app/controllers/oauth_clients_controller.rb' + - 'app/controllers/redactions_controller.rb' + - 'app/controllers/traces_controller.rb' + - 'app/controllers/users_controller.rb' + # Offense count: 5 # Configuration parameters: Database, Include. # SupportedDatabases: mysql, postgresql diff --git a/app/controllers/confirmations_controller.rb b/app/controllers/confirmations_controller.rb index e54fa4a5d..06e7c8e7d 100644 --- a/app/controllers/confirmations_controller.rb +++ b/app/controllers/confirmations_controller.rb @@ -93,13 +93,13 @@ class ConfirmationsController < ApplicationController current_user.tokens.delete_all session[:user] = current_user.id session[:fingerprint] = current_user.fingerprint - redirect_to edit_account_path elsif token flash[:error] = t "confirmations.confirm_email.failure" - redirect_to edit_account_path else flash[:error] = t "confirmations.confirm_email.unknown_token" end + + redirect_to edit_account_path end end diff --git a/test/controllers/confirmations_controller_test.rb b/test/controllers/confirmations_controller_test.rb index 1ab4d253e..083619962 100644 --- a/test/controllers/confirmations_controller_test.rb +++ b/test/controllers/confirmations_controller_test.rb @@ -299,8 +299,8 @@ class UsersControllerTest < ActionDispatch::IntegrationTest def test_confirm_email_bad_token post user_confirm_email_path, :params => { :confirm_string => "XXXXX" } - assert_response :success - assert_template :confirm_email + assert_response :redirect + assert_redirected_to edit_account_path assert_match(/confirmation code has expired or does not exist/, flash[:error]) end