Fix new rubocop warnings

This commit is contained in:
Tom Hughes 2018-09-22 17:12:29 +01:00
parent fbd6909b91
commit 6c2093b29d
21 changed files with 51 additions and 0 deletions

View file

@ -143,6 +143,7 @@ class AmfController < ApplicationController
if cstags
return -1, "One of the tags is invalid. Linux users may need to upgrade to Flash Player 10.1." unless tags_ok(cstags)
cstags = strip_non_xml_chars cstags
end
@ -497,6 +498,7 @@ class AmfController < ApplicationController
rel = Relation.where(:id => relid).first
return [-4, "relation", relid] if rel.nil? || !rel.visible
[0, "", relid, rel.tags, rel.members, rel.version]
end
end
@ -533,6 +535,7 @@ class AmfController < ApplicationController
return -1, "You must accept the contributor terms before you can edit." if REQUIRE_TERMS_AGREED && user.terms_agreed.nil?
return -1, "One of the tags is invalid. Linux users may need to upgrade to Flash Player 10.1." unless tags_ok(tags)
tags = strip_non_xml_chars tags
relid = relid.to_i
@ -622,6 +625,7 @@ class AmfController < ApplicationController
return -2, "Server error - way is only #{pointlist.length} points long." if pointlist.length < 2
return -1, "One of the tags is invalid. Linux users may need to upgrade to Flash Player 10.1." unless tags_ok(attributes)
attributes = strip_non_xml_chars attributes
originalway = originalway.to_i
@ -651,6 +655,7 @@ class AmfController < ApplicationController
# fixup node tags in a way as well
return -1, "One of the tags is invalid. Linux users may need to upgrade to Flash Player 10.1." unless tags_ok(node.tags)
node.tags = strip_non_xml_chars node.tags
node.tags.delete("created_by")
@ -728,6 +733,7 @@ class AmfController < ApplicationController
return -1, "You must accept the contributor terms before you can edit." if REQUIRE_TERMS_AGREED && user.terms_agreed.nil?
return -1, "One of the tags is invalid. Linux users may need to upgrade to Flash Player 10.1." unless tags_ok(tags)
tags = strip_non_xml_chars tags
id = id.to_i

View file

@ -481,6 +481,7 @@ class ChangesetController < ApplicationController
u = if name.nil?
# user input checking, we don't have any UIDs < 1
raise OSM::APIBadUserInput, "invalid user ID" if user.to_i < 1
u = User.find(user.to_i)
else
u = User.find_by(:display_name => name)

View file

@ -54,6 +54,7 @@ class NodeController < ApplicationController
new_node = Node.from_xml(request.raw_post)
raise OSM::APIBadUserInput, "The id in the url (#{node.id}) is not the same as provided in the xml (#{new_node.id})" unless new_node && new_node.id == node.id
node.delete_with_history!(new_node, current_user)
render :plain => node.version.to_s
end
@ -65,6 +66,7 @@ class NodeController < ApplicationController
ids = params["nodes"].split(",").collect(&:to_i)
raise OSM::APIBadUserInput, "No nodes were given to search for" if ids.empty?
doc = OSM::API.new.get_xml_doc
Node.find(ids).each do |node|

View file

@ -826,6 +826,7 @@ class UserController < ApplicationController
def gravatar_enable(user)
# code from example https://en.gravatar.com/site/implement/images/ruby/
return false if user.image.present?
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
response = OSM.http_client.get(URI.parse(url))