From: Tom Hughes Date: Sun, 9 Aug 2020 18:46:16 +0000 (+0100) Subject: Fix some Style/StringConcatenation warnings X-Git-Tag: live~2562 X-Git-Url: https://git.openstreetmap.org./rails.git/commitdiff_plain/abca51e4d8a51cb484598840a1b2459c651e1e67 Fix some Style/StringConcatenation warnings --- diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 3f6abc470..8adea79a4 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -216,7 +216,7 @@ class ApplicationController < ActionController::Base # asserts that the request method is the +method+ given as a parameter # or raises a suitable error. +method+ should be a symbol, e.g: :put or :get. def assert_method(method) - ok = request.send((method.to_s.downcase + "?").to_sym) + ok = request.send(:"#{method.to_s.downcase}?") raise OSM::APIBadMethodError, method unless ok end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index aa9a4f02a..ed9c124b1 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -359,7 +359,7 @@ class UsersController < ApplicationController gravatar_enabled = gravatar_enable(current_user) if current_user.save flash[:notice] = if gravatar_enabled - t("users.confirm_email.success") + " " + gravatar_status_message(current_user) + "#{t('users.confirm_email.success')} #{gravatar_status_message(current_user)}" else t("users.confirm_email.success") end @@ -494,7 +494,7 @@ class UsersController < ApplicationController ## # omniauth failure callback def auth_failure - flash[:error] = t("users.auth_failure." + params[:message]) + flash[:error] = t("users.auth_failure.#{params[:message]}") redirect_to params[:origin] || login_url end @@ -524,7 +524,7 @@ class UsersController < ApplicationController if referer.nil? params[:origin] = request.path else - params[:origin] = request.path + "?referer=" + CGI.escape(referer) + params[:origin] = "#{request.path}?referer=#{CGI.escape(referer)}" params[:referer] = referer end diff --git a/app/helpers/browse_helper.rb b/app/helpers/browse_helper.rb index 4519567d2..1e9465f80 100644 --- a/app/helpers/browse_helper.rb +++ b/app/helpers/browse_helper.rb @@ -44,7 +44,7 @@ module BrowseHelper if object.redacted? "" else - h(icon_tags(object).map { |k, v| k + "=" + v }.to_sentence) + h(icon_tags(object).map { |k, v| "#{k}=#{v}" }.to_sentence) end end diff --git a/script/locale/yaml2po b/script/locale/yaml2po index dbfa1eb74..e1233fcd6 100755 --- a/script/locale/yaml2po +++ b/script/locale/yaml2po @@ -13,14 +13,14 @@ require "yaml" require "optparse" LOCALE_DIR = File.dirname(__FILE__) + "/../../config/locales/" -EN = YAML.load_file(LOCALE_DIR + "en.yml") +EN = YAML.load_file("#{LOCALE_DIR}en.yml") def iterate(hash, fhash = {}, path = "", outfile = $stdout) hash.each do |key, val| fhash[key] = {} unless fhash.key? key if val.is_a? Hash fhash[key] = {} unless fhash[key].is_a? Hash - iterate(val, fhash[key], path + key + ":", outfile) + iterate(val, fhash[key], "#{path}#{key}:#{outfile}") else outfile.puts "msgctxt \"#{path}#{key}\"" outfile.puts "msgid \"#{val}\"" @@ -31,7 +31,7 @@ end def lang2po(lang, outfile = $stdout) puts lang - infile = LOCALE_DIR + lang + ".yml" + infile = "#{LOCALE_DIR}#{lang}.yml" if File.exist? infile oth = YAML.load_file(infile) oth = oth[lang] @@ -44,17 +44,17 @@ end opt = ARGV[0] if opt == "--all" # Produce .po files for all langs, and a .pot template - PO_DIR = LOCALE_DIR + "po/" - Dir.mkdir(PO_DIR) unless File.directory?(PO_DIR) - Dir.glob(LOCALE_DIR + "*.yml") do |filename| + po_dir = "#{LOCALE_DIR}po/" + Dir.mkdir(po_dir) unless File.directory?(po_dir) + Dir.glob("#{LOCALE_DIR}/*.yml") do |filename| lang = File.basename(filename, ".yml") unless lang == "en" - outfile = File.new(PO_DIR + "#{lang}.po", "w") + outfile = File.new("#{po_dir}#{lang}.po", "w") lang2po(lang, outfile) outfile.close end end - outfile = File.new(PO_DIR + "rails_port.pot", "w") + outfile = File.new("#{po_dir}rails_port.pot", "w") iterate(EN["en"], {}, "", outfile) outfile.close elsif opt diff --git a/test/integration/short_links_test.rb b/test/integration/short_links_test.rb index 0d42ae738..c03ebedab 100644 --- a/test/integration/short_links_test.rb +++ b/test/integration/short_links_test.rb @@ -16,21 +16,21 @@ class ShortLinksTest < ActionDispatch::IntegrationTest anchor = "map=#{zoom}/#{lat}/#{lon}" # test without marker - get "/go/" + short_link + get "/go/#{short_link}" assert_redirected_to :controller => "site", :action => "index", :anchor => anchor # test with marker - get "/go/" + short_link + "?m" + get "/go/#{short_link}?m" assert_redirected_to :controller => "site", :action => "index", :mlat => lat.to_s, :mlon => lon.to_s, :anchor => anchor # test with layers and a marker - get "/go/" + short_link + "?m&layers=B000FTF" + get "/go/#{short_link}?m&layers=B000FTF" assert_redirected_to :controller => "site", :action => "index", :mlat => lat.to_s, :mlon => lon.to_s, :anchor => "#{anchor}&layers=B000FTF" - get "/go/" + short_link + "?layers=B000FTF&m" + get "/go/#{short_link}?layers=B000FTF&m" assert_redirected_to :controller => "site", :action => "index", :mlat => lat.to_s, :mlon => lon.to_s, :anchor => "#{anchor}&layers=B000FTF" # test with some random query parameters we haven't even implemented yet - get "/go/" + short_link + "?foobar=yes" + get "/go/#{short_link}?foobar=yes" assert_redirected_to :controller => "site", :action => "index", :foobar => "yes", :anchor => anchor end end