Fix new rubocop warnings
This commit is contained in:
parent
0674fc58b8
commit
d82f9d12ce
10 changed files with 14 additions and 14 deletions
|
@ -86,14 +86,14 @@ class AmfController < ApplicationController
|
||||||
orn = renumberednodes.dup
|
orn = renumberednodes.dup
|
||||||
result = putway(renumberednodes, *args)
|
result = putway(renumberednodes, *args)
|
||||||
result[4] = renumberednodes.reject { |k, _v| orn.key?(k) }
|
result[4] = renumberednodes.reject { |k, _v| orn.key?(k) }
|
||||||
renumberedways[result[2]] = result[3] if result[0] == 0 && result[2] != result[3]
|
renumberedways[result[2]] = result[3] if result[0].zero? && result[2] != result[3]
|
||||||
when "putrelation" then
|
when "putrelation" then
|
||||||
result = putrelation(renumberednodes, renumberedways, *args)
|
result = putrelation(renumberednodes, renumberedways, *args)
|
||||||
when "deleteway" then
|
when "deleteway" then
|
||||||
result = deleteway(*args)
|
result = deleteway(*args)
|
||||||
when "putpoi" then
|
when "putpoi" then
|
||||||
result = putpoi(*args)
|
result = putpoi(*args)
|
||||||
renumberednodes[result[2]] = result[3] if result[0] == 0 && result[2] != result[3]
|
renumberednodes[result[2]] = result[3] if result[0].zero? && result[2] != result[3]
|
||||||
when "startchangeset" then
|
when "startchangeset" then
|
||||||
result = startchangeset(*args)
|
result = startchangeset(*args)
|
||||||
end
|
end
|
||||||
|
@ -163,7 +163,7 @@ class AmfController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
# open a new changeset
|
# open a new changeset
|
||||||
if opennew != 0
|
if opennew.nonzero?
|
||||||
cs = Changeset.new
|
cs = Changeset.new
|
||||||
cs.tags = cstags
|
cs.tags = cstags
|
||||||
cs.user_id = user.id
|
cs.user_id = user.id
|
||||||
|
@ -540,7 +540,7 @@ class AmfController < ApplicationController
|
||||||
tags = strip_non_xml_chars tags
|
tags = strip_non_xml_chars tags
|
||||||
|
|
||||||
relid = relid.to_i
|
relid = relid.to_i
|
||||||
visible = (visible.to_i != 0)
|
visible = visible.to_i.nonzero?
|
||||||
|
|
||||||
new_relation = nil
|
new_relation = nil
|
||||||
relation = nil
|
relation = nil
|
||||||
|
@ -644,7 +644,7 @@ class AmfController < ApplicationController
|
||||||
id = a[2].to_i
|
id = a[2].to_i
|
||||||
version = a[3].to_i
|
version = a[3].to_i
|
||||||
|
|
||||||
return -2, "Server error - node with id 0 found in way #{originalway}." if id == 0
|
return -2, "Server error - node with id 0 found in way #{originalway}." if id.zero?
|
||||||
return -2, "Server error - node with latitude -90 found in way #{originalway}." if lat == 90
|
return -2, "Server error - node with latitude -90 found in way #{originalway}." if lat == 90
|
||||||
|
|
||||||
id = renumberednodes[id] if renumberednodes[id]
|
id = renumberednodes[id] if renumberednodes[id]
|
||||||
|
|
|
@ -195,7 +195,7 @@ class SwfController < ApplicationController
|
||||||
# Find number of bits required to store arbitrary-length binary
|
# Find number of bits required to store arbitrary-length binary
|
||||||
|
|
||||||
def length_sb(n)
|
def length_sb(n)
|
||||||
Math.frexp(n + (n == 0 ? 1 : 0))[1] + 1
|
Math.frexp(n + (n.zero? ? 1 : 0))[1] + 1
|
||||||
end
|
end
|
||||||
|
|
||||||
# ====================================================================
|
# ====================================================================
|
||||||
|
|
|
@ -81,7 +81,7 @@ class Node < ActiveRecord::Base
|
||||||
node.id = pt["id"].to_i
|
node.id = pt["id"].to_i
|
||||||
# .to_i will return 0 if there is no number that can be parsed.
|
# .to_i will return 0 if there is no number that can be parsed.
|
||||||
# We want to make sure that there is no id with zero anyway
|
# We want to make sure that there is no id with zero anyway
|
||||||
raise OSM::APIBadUserInput.new("ID of node cannot be zero when updating.") if node.id == 0
|
raise OSM::APIBadUserInput.new("ID of node cannot be zero when updating.") if node.id.zero?
|
||||||
end
|
end
|
||||||
|
|
||||||
# We don't care about the time, as it is explicitly set on create/update/delete
|
# We don't care about the time, as it is explicitly set on create/update/delete
|
||||||
|
|
|
@ -60,7 +60,7 @@ class Relation < ActiveRecord::Base
|
||||||
relation.id = pt["id"].to_i
|
relation.id = pt["id"].to_i
|
||||||
# .to_i will return 0 if there is no number that can be parsed.
|
# .to_i will return 0 if there is no number that can be parsed.
|
||||||
# We want to make sure that there is no id with zero anyway
|
# We want to make sure that there is no id with zero anyway
|
||||||
raise OSM::APIBadUserInput.new("ID of relation cannot be zero when updating.") if relation.id == 0
|
raise OSM::APIBadUserInput.new("ID of relation cannot be zero when updating.") if relation.id.zero?
|
||||||
end
|
end
|
||||||
|
|
||||||
# We don't care about the timestamp nor the visibility as these are either
|
# We don't care about the timestamp nor the visibility as these are either
|
||||||
|
|
|
@ -197,7 +197,7 @@ class Trace < ActiveRecord::Base
|
||||||
trace.id = pt["id"].to_i
|
trace.id = pt["id"].to_i
|
||||||
# .to_i will return 0 if there is no number that can be parsed.
|
# .to_i will return 0 if there is no number that can be parsed.
|
||||||
# We want to make sure that there is no id with zero anyway
|
# We want to make sure that there is no id with zero anyway
|
||||||
raise OSM::APIBadUserInput.new("ID of trace cannot be zero when updating.") if trace.id == 0
|
raise OSM::APIBadUserInput.new("ID of trace cannot be zero when updating.") if trace.id.zero?
|
||||||
end
|
end
|
||||||
|
|
||||||
# We don't care about the time, as it is explicitly set on create/update/delete
|
# We don't care about the time, as it is explicitly set on create/update/delete
|
||||||
|
|
|
@ -58,7 +58,7 @@ class Way < ActiveRecord::Base
|
||||||
way.id = pt["id"].to_i
|
way.id = pt["id"].to_i
|
||||||
# .to_i will return 0 if there is no number that can be parsed.
|
# .to_i will return 0 if there is no number that can be parsed.
|
||||||
# We want to make sure that there is no id with zero anyway
|
# We want to make sure that there is no id with zero anyway
|
||||||
raise OSM::APIBadUserInput.new("ID of way cannot be zero when updating.") if way.id == 0
|
raise OSM::APIBadUserInput.new("ID of way cannot be zero when updating.") if way.id.zero?
|
||||||
end
|
end
|
||||||
|
|
||||||
# We don't care about the timestamp nor the visibility as these are either
|
# We don't care about the timestamp nor the visibility as these are either
|
||||||
|
|
|
@ -2,7 +2,7 @@ require "migrate"
|
||||||
|
|
||||||
class RemoveSegments < ActiveRecord::Migration
|
class RemoveSegments < ActiveRecord::Migration
|
||||||
def self.up
|
def self.up
|
||||||
have_segs = select_value("SELECT count(*) FROM current_segments").to_i != 0
|
have_segs = select_value("SELECT count(*) FROM current_segments").to_i.nonzero?
|
||||||
|
|
||||||
if have_segs
|
if have_segs
|
||||||
prefix = File.join Dir.tmpdir, "008_remove_segments.#{$PROCESS_ID}."
|
prefix = File.join Dir.tmpdir, "008_remove_segments.#{$PROCESS_ID}."
|
||||||
|
|
|
@ -2,7 +2,7 @@ require "migrate"
|
||||||
|
|
||||||
class PopulateNodeTagsAndRemove < ActiveRecord::Migration
|
class PopulateNodeTagsAndRemove < ActiveRecord::Migration
|
||||||
def self.up
|
def self.up
|
||||||
have_nodes = select_value("SELECT count(*) FROM current_nodes").to_i != 0
|
have_nodes = select_value("SELECT count(*) FROM current_nodes").to_i.nonzero?
|
||||||
|
|
||||||
if have_nodes
|
if have_nodes
|
||||||
prefix = File.join Dir.tmpdir, "020_populate_node_tags_and_remove.#{$PROCESS_ID}."
|
prefix = File.join Dir.tmpdir, "020_populate_node_tags_and_remove.#{$PROCESS_ID}."
|
||||||
|
|
|
@ -273,7 +273,7 @@ module ActionController
|
||||||
1
|
1
|
||||||
else
|
else
|
||||||
q, r = @item_count.divmod(@items_per_page)
|
q, r = @item_count.divmod(@items_per_page)
|
||||||
r == 0 ? q : q + 1
|
r.zero? ? q : q + 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
start = 0
|
start = 0
|
||||||
User.where("image_use_gravatar AND id >=" + start.to_s).order("id").find_each do |user|
|
User.where("image_use_gravatar AND id >=" + start.to_s).order("id").find_each do |user|
|
||||||
p "checked up to id " + user.id.to_s if user.id % 1000 == 0 # just give a rough indication where we are for restarting
|
p "checked up to id " + user.id.to_s if (user.id % 1000).zero? # just give a rough indication where we are for restarting
|
||||||
next if user.image.present?
|
next if user.image.present?
|
||||||
hash = Digest::MD5.hexdigest(user.email.downcase)
|
hash = Digest::MD5.hexdigest(user.email.downcase)
|
||||||
url = "https://www.gravatar.com/avatar/#{hash}?d=404" # without d=404 we will always get an image back
|
url = "https://www.gravatar.com/avatar/#{hash}?d=404" # without d=404 we will always get an image back
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue