From: Tom Hughes Date: Tue, 22 Nov 2022 18:32:02 +0000 (+0000) Subject: Fix new rubocop warnings X-Git-Tag: live~1470 X-Git-Url: https://git.openstreetmap.org./rails.git/commitdiff_plain/dc28f1dccc5589afa667bf6959f12e6b18589459 Fix new rubocop warnings --- diff --git a/app/controllers/confirmations_controller.rb b/app/controllers/confirmations_controller.rb index 06e7c8e7d..a482bc96d 100644 --- a/app/controllers/confirmations_controller.rb +++ b/app/controllers/confirmations_controller.rb @@ -16,10 +16,10 @@ class ConfirmationsController < ApplicationController if request.post? token = UserToken.find_by(:token => params[:confirm_string]) if token&.user&.active? - flash[:error] = t("confirmations.confirm.already active") + flash[:error] = t(".already active") redirect_to login_path elsif !token || token.expired? - flash[:error] = t("confirmations.confirm.unknown token") + flash[:error] = t(".unknown token") redirect_to :action => "confirm" elsif !token.user.visible? render_unknown_user token.user.display_name @@ -40,7 +40,7 @@ class ConfirmationsController < ApplicationController end if token.nil? || token.user != user - flash[:notice] = t("confirmations.confirm.success") + flash[:notice] = t(".success") redirect_to login_path(:referer => referer) else token.destroy @@ -63,7 +63,7 @@ class ConfirmationsController < ApplicationController token = UserToken.find_by(:token => session[:token]) if user.nil? || token.nil? || token.user != user - flash[:error] = t "confirmations.confirm_resend.failure", :name => params[:display_name] + flash[:error] = t ".failure", :name => params[:display_name] else UserMailer.signup_confirm(user, user.tokens.create).deliver_later flash[:notice] = { :partial => "confirmations/resend_success_flash", :locals => { :email => user.email, :sender => Settings.email_from } } @@ -83,9 +83,9 @@ class ConfirmationsController < ApplicationController gravatar_enabled = gravatar_enable(current_user) if current_user.save flash[:notice] = if gravatar_enabled - "#{t('confirmations.confirm_email.success')} #{gravatar_status_message(current_user)}" + "#{t('.success')} #{gravatar_status_message(current_user)}" else - t("confirmations.confirm_email.success") + t(".success") end else flash[:errors] = current_user.errors @@ -94,9 +94,9 @@ class ConfirmationsController < ApplicationController session[:user] = current_user.id session[:fingerprint] = current_user.fingerprint elsif token - flash[:error] = t "confirmations.confirm_email.failure" + flash[:error] = t ".failure" else - flash[:error] = t "confirmations.confirm_email.unknown_token" + flash[:error] = t ".unknown_token" end redirect_to edit_account_path diff --git a/app/controllers/diary_entries_controller.rb b/app/controllers/diary_entries_controller.rb index 8e6215dbd..4cdc1b55a 100644 --- a/app/controllers/diary_entries_controller.rb +++ b/app/controllers/diary_entries_controller.rb @@ -16,7 +16,7 @@ class DiaryEntriesController < ApplicationController @user = User.active.find_by(:display_name => params[:display_name]) if @user - @title = t "diary_entries.index.user_title", :user => @user.display_name + @title = t ".user_title", :user => @user.display_name @entries = @user.diary_entries else render_unknown_user params[:display_name] @@ -24,7 +24,7 @@ class DiaryEntriesController < ApplicationController end elsif params[:friends] if current_user - @title = t "diary_entries.index.title_friends" + @title = t ".title_friends" @entries = DiaryEntry.where(:user_id => current_user.friends) else require_user @@ -32,7 +32,7 @@ class DiaryEntriesController < ApplicationController end elsif params[:nearby] if current_user - @title = t "diary_entries.index.title_nearby" + @title = t ".title_nearby" @entries = DiaryEntry.where(:user_id => current_user.nearby) else require_user @@ -42,10 +42,10 @@ class DiaryEntriesController < ApplicationController @entries = DiaryEntry.joins(:user).where(:users => { :status => %w[active confirmed] }) if params[:language] - @title = t "diary_entries.index.in_language_title", :language => Language.find(params[:language]).english_name + @title = t ".in_language_title", :language => Language.find(params[:language]).english_name @entries = @entries.where(:language_code => params[:language]) else - @title = t "diary_entries.index.title" + @title = t ".title" end end @@ -64,7 +64,7 @@ class DiaryEntriesController < ApplicationController def show @entry = @user.diary_entries.visible.where(:id => params[:id]).first if @entry - @title = t "diary_entries.show.title", :user => params[:display_name], :title => @entry.title + @title = t ".title", :user => params[:display_name], :title => @entry.title @comments = can?(:unhidecomment, DiaryEntry) ? @entry.comments : @entry.visible_comments else @title = t "diary_entries.no_such_entry.title", :id => params[:id] @@ -73,7 +73,7 @@ class DiaryEntriesController < ApplicationController end def new - @title = t "diary_entries.new.title" + @title = t ".title" default_lang = current_user.preferences.where(:k => "diary.default_language").first lang_code = default_lang ? default_lang.v : current_user.preferred_language @@ -83,7 +83,7 @@ class DiaryEntriesController < ApplicationController end def edit - @title = t "diary_entries.edit.title" + @title = t ".title" @diary_entry = DiaryEntry.find(params[:id]) redirect_to diary_entry_path(@diary_entry.user, @diary_entry) if current_user != @diary_entry.user diff --git a/app/controllers/friendships_controller.rb b/app/controllers/friendships_controller.rb index 5bfce7f0b..4d1161147 100644 --- a/app/controllers/friendships_controller.rb +++ b/app/controllers/friendships_controller.rb @@ -18,14 +18,14 @@ class FriendshipsController < ApplicationController friendship.befriender = current_user friendship.befriendee = @new_friend if current_user.friends_with?(@new_friend) - flash[:warning] = t "friendships.make_friend.already_a_friend", :name => @new_friend.display_name + flash[:warning] = t ".already_a_friend", :name => @new_friend.display_name elsif current_user.friendships.where("created_at >= ?", Time.now.utc - 1.hour).count >= current_user.max_friends_per_hour - flash.now[:error] = t "friendships.make_friend.limit_exceeded" + flash.now[:error] = t ".limit_exceeded" elsif friendship.save - flash[:notice] = t "friendships.make_friend.success", :name => @new_friend.display_name + flash[:notice] = t ".success", :name => @new_friend.display_name UserMailer.friendship_notification(friendship).deliver_later else - friendship.add_error(t("friendships.make_friend.failed", :name => @new_friend.display_name)) + friendship.add_error(t(".failed", :name => @new_friend.display_name)) end referer = safe_referer(params[:referer]) if params[:referer] @@ -44,9 +44,9 @@ class FriendshipsController < ApplicationController if request.post? if current_user.friends_with?(@friend) Friendship.where(:befriender => current_user, :befriendee => @friend).delete_all - flash[:notice] = t "friendships.remove_friend.success", :name => @friend.display_name + flash[:notice] = t ".success", :name => @friend.display_name else - flash[:error] = t "friendships.remove_friend.not_a_friend", :name => @friend.display_name + flash[:error] = t ".not_a_friend", :name => @friend.display_name end referer = safe_referer(params[:referer]) if params[:referer] diff --git a/app/controllers/geocoder_controller.rb b/app/controllers/geocoder_controller.rb index 02f00ff7f..4f9efa4dc 100644 --- a/app/controllers/geocoder_controller.rb +++ b/app/controllers/geocoder_controller.rb @@ -154,7 +154,7 @@ class GeocoderController < ApplicationController prefix_name = t "geocoder.search_osm_nominatim.prefix.place.#{extratag.attributes['value']}", :default => prefix_name if extratag.attributes["key"] == "linked_place" || extratag.attributes["key"] == "place" end end - prefix = t "geocoder.search_osm_nominatim.prefix_format", :name => prefix_name + prefix = t ".prefix_format", :name => prefix_name object_type = place.attributes["osm_type"] object_id = place.attributes["osm_id"] diff --git a/app/controllers/oauth_clients_controller.rb b/app/controllers/oauth_clients_controller.rb index c17d3856d..44dacde6d 100644 --- a/app/controllers/oauth_clients_controller.rb +++ b/app/controllers/oauth_clients_controller.rb @@ -32,7 +32,7 @@ class OauthClientsController < ApplicationController def create @client_application = current_user.client_applications.build(application_params) if @client_application.save - flash[:notice] = t "oauth_clients.create.flash" + flash[:notice] = t ".flash" redirect_to :action => "show", :id => @client_application.id else render :action => "new" @@ -42,7 +42,7 @@ class OauthClientsController < ApplicationController def update @client_application = current_user.client_applications.find(params[:id]) if @client_application.update(application_params) - flash[:notice] = t "oauth_clients.update.flash" + flash[:notice] = t ".flash" redirect_to :action => "show", :id => @client_application.id else render :action => "edit" @@ -55,7 +55,7 @@ class OauthClientsController < ApplicationController def destroy @client_application = current_user.client_applications.find(params[:id]) @client_application.destroy - flash[:notice] = t "oauth_clients.destroy.flash" + flash[:notice] = t ".flash" redirect_to :action => "index" rescue ActiveRecord::RecordNotFound @type = "client application" diff --git a/app/controllers/passwords_controller.rb b/app/controllers/passwords_controller.rb index 502b1357f..08df9f7a4 100644 --- a/app/controllers/passwords_controller.rb +++ b/app/controllers/passwords_controller.rb @@ -12,7 +12,7 @@ class PasswordsController < ApplicationController before_action :check_database_writable, :only => [:lost_password, :reset_password] def lost_password - @title = t "passwords.lost_password.title" + @title = t ".title" if request.post? user = User.visible.find_by(:email => params[:email]) @@ -26,16 +26,16 @@ class PasswordsController < ApplicationController if user token = user.tokens.create UserMailer.lost_password(user, token).deliver_later - flash[:notice] = t "passwords.lost_password.notice email on way" + flash[:notice] = t ".notice email on way" redirect_to login_path else - flash.now[:error] = t "passwords.lost_password.notice email cannot find" + flash.now[:error] = t ".notice email cannot find" end end end def reset_password - @title = t "passwords.reset_password.title" + @title = t ".title" if params[:token] token = UserToken.find_by(:token => params[:token]) @@ -52,12 +52,12 @@ class PasswordsController < ApplicationController if current_user.save token.destroy session[:fingerprint] = current_user.fingerprint - flash[:notice] = t "passwords.reset_password.flash changed" + flash[:notice] = t ".flash changed" successful_login(current_user) end end else - flash[:error] = t "passwords.reset_password.flash token bad" + flash[:error] = t ".flash token bad" redirect_to :action => "lost_password" end else diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb index 2e2233939..ba2858ce4 100644 --- a/app/controllers/sessions_controller.rb +++ b/app/controllers/sessions_controller.rb @@ -24,7 +24,7 @@ class SessionsController < ApplicationController end def destroy - @title = t "sessions.destroy.title" + @title = t ".title" if request.post? if session[:token] diff --git a/app/controllers/traces_controller.rb b/app/controllers/traces_controller.rb index 86b09215e..855bbb78a 100644 --- a/app/controllers/traces_controller.rb +++ b/app/controllers/traces_controller.rb @@ -119,7 +119,7 @@ class TracesController < ApplicationController TraceImporterJob.perform_later(@trace) redirect_to :action => :index, :display_name => current_user.display_name else - flash[:error] = t("traces.create.upload_failed") if @trace.valid? + flash[:error] = t(".upload_failed") if @trace.valid? render :action => "new" end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 1e927aa01..6d98c17f6 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -53,7 +53,7 @@ class UsersController < ApplicationController end def new - @title = t "users.new.title" + @title = t ".title" @referer = if params[:referer] safe_referer(params[:referer]) else @@ -127,7 +127,7 @@ class UsersController < ApplicationController if request.xhr? render :partial => "terms" else - @title = t "users.terms.title" + @title = t ".title" if current_user&.terms_agreed? # Already agreed to terms, so just show settings @@ -220,7 +220,7 @@ class UsersController < ApplicationController def go_public current_user.data_public = true current_user.save - flash[:notice] = t "users.go_public.flash success" + flash[:notice] = t ".flash success" redirect_to edit_account_path end @@ -304,7 +304,7 @@ class UsersController < ApplicationController ## # omniauth failure callback def auth_failure - flash[:error] = t(params[:message], :scope => "users.auth_failure", :default => t("users.auth_failure.unknown_error")) + flash[:error] = t(params[:message], :scope => "users.auth_failure", :default => t(".unknown_error")) origin = safe_referer(params[:origin]) if params[:origin]