]> git.openstreetmap.org Git - rails.git/commitdiff
Fix new rubocop warnings
authorTom Hughes <tom@compton.nu>
Tue, 14 Jan 2025 18:31:52 +0000 (18:31 +0000)
committerTom Hughes <tom@compton.nu>
Tue, 14 Jan 2025 18:31:52 +0000 (18:31 +0000)
app/controllers/application_controller.rb
app/controllers/geocoder_controller.rb
app/controllers/site_controller.rb
app/models/trace.rb

index 25c430f1c0290d02b01a89a412d6eb1fc68aae05..f6006fe5e4ccdc7139a6db14d5e0cf7adf5ee748 100644 (file)
@@ -114,7 +114,7 @@ class ApplicationController < ActionController::Base
 
   def check_database_writable(need_api: false)
     if Settings.status == "database_offline" || Settings.status == "database_readonly" ||
-       (need_api && (Settings.status == "api_offline" || Settings.status == "api_readonly"))
+       (need_api && %w[api_offline api_readonly].include?(Settings.status))
       if request.xhr?
         report_error "Database offline for maintenance", :service_unavailable
       else
@@ -339,7 +339,7 @@ class ApplicationController < ActionController::Base
     begin
       referer = URI.parse(referer)
 
-      if referer.scheme == "http" || referer.scheme == "https"
+      if %w[http https].include?(referer.scheme)
         referer.scheme = nil
         referer.host = nil
         referer.port = nil
index 43f276efa020a35cfdbb1719155c4a3f5e61c1fe..85b4476f6d4f2d620b65a4244bb23e7b0b458a20 100644 (file)
@@ -101,8 +101,9 @@ class GeocoderController < ApplicationController
       if klass == "boundary" && type == "administrative"
         rank = (place.attributes["address_rank"].to_i + 1) / 2
         prefix_name = t "geocoder.search_osm_nominatim.admin_levels.level#{rank}", :default => prefix_name
+        place_tags = %w[linked_place place]
         place.elements["extratags"].elements.each("tag") do |extratag|
-          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"
+          prefix_name = t "geocoder.search_osm_nominatim.prefix.place.#{extratag.attributes['value']}", :default => prefix_name if place_tags.include?(extratag.attributes["key"])
         end
       end
       prefix = t ".prefix_format", :name => prefix_name
index 58f0a11c9340bbd796082622f3d6dcdbe852d13d..9adbaa1953fd9fe774bf9bb90eb130da53aed90e 100644 (file)
@@ -24,7 +24,7 @@ class SiteController < ApplicationController
   end
 
   def index
-    session[:location] ||= OSM.ip_location(request.env["REMOTE_ADDR"]) unless Settings.status == "database_readonly" || Settings.status == "database_offline"
+    session[:location] ||= OSM.ip_location(request.env["REMOTE_ADDR"]) unless %w[database_readonly database_offline].include?(Settings.status)
   end
 
   def permalink
index 20723b98d01ddc7e0efe3d732879c12c8345d77b..4d71b4b2933d02fdd63453147970f36d8369b24e 100644 (file)
@@ -86,11 +86,11 @@ class Trace < ApplicationRecord
   end
 
   def public?
-    visibility == "public" || visibility == "identifiable"
+    %w[public identifiable].include?(visibility)
   end
 
   def trackable?
-    visibility == "trackable" || visibility == "identifiable"
+    %w[trackable identifiable].include?(visibility)
   end
 
   def identifiable?