From c886971abbe449199fee7fb9ed2676704a5e7daf Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Tue, 2 May 2023 12:39:22 -0400 Subject: [PATCH] Fix Rails/DeprecatedActiveModelErrorsMethods cop (#24742) --- .rubocop_todo.yml | 6 ------ lib/mastodon/accounts_cli.rb | 12 ++++++------ 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index b9111fcd5b..9c0f25848c 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1169,12 +1169,6 @@ Rails/CreateTableWithTimestamps: - 'db/migrate/20220824233535_create_status_trends.rb' - 'db/migrate/20221006061337_create_preview_card_trends.rb' -# This cop supports unsafe autocorrection (--autocorrect-all). -# Configuration parameters: Severity. -Rails/DeprecatedActiveModelErrorsMethods: - Exclude: - - 'lib/mastodon/accounts_cli.rb' - # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: Severity. Rails/DuplicateAssociation: diff --git a/lib/mastodon/accounts_cli.rb b/lib/mastodon/accounts_cli.rb index db0565730e..c09577c9ef 100644 --- a/lib/mastodon/accounts_cli.rb +++ b/lib/mastodon/accounts_cli.rb @@ -121,10 +121,10 @@ module Mastodon say('OK', :green) say("New password: #{password}") else - user.errors.to_h.each do |key, error| + user.errors.each do |error| say('Failure/Error: ', :red) - say(key) - say(" #{error}", :red) + say(error.attribute) + say(" #{error.type}", :red) end exit(1) @@ -197,10 +197,10 @@ module Mastodon say('OK', :green) say("New password: #{password}") if options[:reset_password] else - user.errors.to_h.each do |key, error| + user.errors.each do |error| say('Failure/Error: ', :red) - say(key) - say(" #{error}", :red) + say(error.attribute) + say(" #{error.type}", :red) end exit(1)