]> git.openstreetmap.org Git - rails.git/commitdiff
Fix new rubocop warnings
authorTom Hughes <tom@compton.nu>
Fri, 9 Sep 2022 21:36:39 +0000 (22:36 +0100)
committerTom Hughes <tom@compton.nu>
Fri, 9 Sep 2022 21:45:58 +0000 (22:45 +0100)
app/controllers/preferences_controller.rb
app/controllers/profiles_controller.rb
app/controllers/reports_controller.rb
app/mailers/user_mailer.rb
config/initializers/config.rb
lib/country.rb
test/models/trace_test.rb

index e098a8acc49a989a58b390e1cfb3a27570e23d95..dcf0d8b64e2682364b7c5b489ad1c9c72662bd19 100644 (file)
@@ -26,7 +26,7 @@ class PreferencesController < ApplicationController
       flash[:notice] = { :partial => "preferences/update_success_flash" }
       redirect_to preferences_path
     else
-      flash[:error] = t ".failure"
+      flash.now[:error] = t ".failure"
       render :edit
     end
   end
index b48d08ad2ebece1d3fb14ed1ffaa18fbe6d18968..4005176ce192c529d8f4f535e57ada04569f1622 100644 (file)
@@ -36,7 +36,7 @@ class ProfilesController < ApplicationController
       flash[:notice] = t ".success"
       redirect_to user_path(current_user)
     else
-      flash[:error] = t ".failure"
+      flash.now[:error] = t ".failure"
       render :edit
     end
   end
index 30cb9da7cc18c526ab9b93eabbb338cf72fbf2a8..6d05e6a57b7f24042ffcb781e8952cbeb7f52bd5 100644 (file)
@@ -28,7 +28,7 @@ class ReportsController < ApplicationController
 
       redirect_to helpers.reportable_url(@report.issue.reportable), :notice => t(".successful_report")
     else
-      flash[:notice] = t(".provide_details")
+      flash.now[:notice] = t(".provide_details")
       render :action => "new"
     end
   end
index 7bbe65ec591d471ccf297878dffdd5b0a027a0c6..33fcc7465a6fb8a056448032556dbf7c577b0b7c 100644 (file)
@@ -183,7 +183,7 @@ class UserMailer < ApplicationMailer
   end
 
   def attach_project_logo
-    attachments.inline["logo.png"] = File.read(Rails.root.join("app/assets/images/osm_logo_30.png"))
+    attachments.inline["logo.png"] = Rails.root.join("app/assets/images/osm_logo_30.png").read
   end
 
   def attach_user_avatar(user)
@@ -199,7 +199,7 @@ class UserMailer < ApplicationMailer
         avatar.blob.download
       end
     else
-      File.read(Rails.root.join("app/assets/images/avatar_small.png"))
+      Rails.root.join("app/assets/images/avatar_small.png").read
     end
   end
 
index e51281e11e034499b26e9ccba6b2bb795ee3456d..7fc48863567b022fe8ac31d726b9ca47e811d9f9 100644 (file)
@@ -2,7 +2,7 @@
 # Otherwise, admins might not be aware that they are now silently ignored
 # and major problems could occur
 # rubocop:disable Rails/Output, Rails/Exit
-if File.exist?(Rails.root.join("config/application.yml"))
+if Rails.root.join("config/application.yml").exist?
   puts "The config/application.yml file is no longer supported."
   puts ""
   puts "Default settings are now found in config/settings.yml and you"
index f6f6791252524e4e1e739d923de3aec138859f75..ca547a972d7df72ccb9bd9c6dc03823b648ee50e 100644 (file)
@@ -19,7 +19,7 @@ class Country
 
   def self.load_countries
     countries = {}
-    xml = REXML::Document.new(File.read(Rails.root.join("config/countries.xml")))
+    xml = REXML::Document.new(Rails.root.join("config/countries.xml").read)
 
     xml.elements.each("geonames/country") do |ele|
       code = ele.get_text("countryCode").to_s
index 8fa09f4d7233c77858b1bf3a0c90a9ae88e24651..762df66484d185c82bc52f305e739a989421a1cc 100644 (file)
@@ -166,14 +166,14 @@ class TraceTest < ActiveSupport::TestCase
   end
 
   def test_large_picture
-    picture = File.read(Rails.root.join("test/gpx/fixtures/a.gif"), :mode => "rb")
+    picture = Rails.root.join("test/gpx/fixtures/a.gif").read(:mode => "rb")
     trace = create(:trace, :fixture => "a")
 
     assert_equal picture, trace.large_picture
   end
 
   def test_icon_picture
-    picture = File.read(Rails.root.join("test/gpx/fixtures/a_icon.gif"), :mode => "rb")
+    picture = Rails.root.join("test/gpx/fixtures/a_icon.gif").read(:mode => "rb")
     trace = create(:trace, :fixture => "a")
 
     assert_equal picture, trace.icon_picture