Skip to content

Commit

Permalink
Fix new rubocop warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
tomhughes committed Jan 14, 2025
1 parent 59f15a9 commit 473aff0
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
4 changes: 2 additions & 2 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def check_database_readable(need_api: false)

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
Expand Down Expand Up @@ -339,7 +339,7 @@ def safe_referer(referer)
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
Expand Down
3 changes: 2 additions & 1 deletion app/controllers/geocoder_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,9 @@ def search_osm_nominatim
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
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/site_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions app/models/trace.rb
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,11 @@ def file=(attachable)
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?
Expand Down

0 comments on commit 473aff0

Please sign in to comment.