Fix rubocop warnings

This commit is contained in:
Tom Hughes 2016-06-09 22:18:28 +01:00
parent 2ea4ecce54
commit 72e71b9972
9 changed files with 26 additions and 35 deletions

View file

@ -300,10 +300,9 @@ class ApiController < ApplicationController
# * if authenticated via basic auth all permissions are granted, so the list will contain all permissions.
# * unauthenticated users have no permissions, so the list will be empty.
def permissions
@permissions = case
when current_token.present?
@permissions = if current_token.present?
ClientApplication.all_permissions.select { |p| current_token.read_attribute(p) }
when @user
elsif @user
ClientApplication.all_permissions
else
[]

View file

@ -3,14 +3,12 @@ module NoteHelper
if by.nil?
I18n.t("browse.note." + event + "_by_anonymous",
:when => friendly_date(at),
:exact_time => l(at)
).html_safe
:exact_time => l(at)).html_safe
else
I18n.t("browse.note." + event + "_by",
:when => friendly_date(at),
:exact_time => l(at),
:user => note_author(by)
).html_safe
:user => note_author(by)).html_safe
end
end

View file

@ -59,11 +59,13 @@ class BoundingBox
# check the bbox is sane
if min_lon > max_lon
raise OSM::APIBadBoundingBox.new(
"The minimum longitude must be less than the maximum longitude, but it wasn't")
"The minimum longitude must be less than the maximum longitude, but it wasn't"
)
end
if min_lat > max_lat
raise OSM::APIBadBoundingBox.new(
"The minimum latitude must be less than the maximum latitude, but it wasn't")
"The minimum latitude must be less than the maximum latitude, but it wasn't"
)
end
if min_lon < -LON_LIMIT || min_lat < -LAT_LIMIT || max_lon > +LON_LIMIT || max_lat > +LAT_LIMIT
raise OSM::APIBadBoundingBox.new("The latitudes must be between #{-LAT_LIMIT} and #{LAT_LIMIT}," +
@ -162,7 +164,8 @@ class BoundingBox
def from_bbox_array(bbox_array)
unless bbox_array
raise OSM::APIBadUserInput.new(
"The parameter bbox is required, and must be of the form min_lon,min_lat,max_lon,max_lat")
"The parameter bbox is required, and must be of the form min_lon,min_lat,max_lon,max_lat"
)
end
# Take an array of length 4, create a bounding box with min_lon, min_lat, max_lon and
# max_lat within their respective boundaries.

View file

@ -15,7 +15,9 @@ options = YAML.load(
ERB.new(
IO.read(
File.dirname(__FILE__) + "/../../config/daemons.yml"
)).result).with_symbols!
)
).result
).with_symbols!
options[:dir_mode] = options[:dir_mode].to_sym
Daemons.run File.dirname(__FILE__) + "/gpx_import.rb", options

View file

@ -308,8 +308,7 @@ class AmfControllerTest < ActionController::TestCase
# try to get version 1
v1 = ways(:way_with_versions_v2)
{ latest.id => "",
v1.way_id => v1.timestamp.strftime("%d %b %Y, %H:%M:%S")
}.each do |id, t|
v1.way_id => v1.timestamp.strftime("%d %b %Y, %H:%M:%S") }.each do |id, t|
amf_content "getway_old", "/1", [id, t]
post :amf_read
assert_response :success
@ -331,8 +330,7 @@ class AmfControllerTest < ActionController::TestCase
way_id => "not a date",
way_id => "2009-03-25 00:00:00", # <- wrong format
way_id => "0 Jan 2009 00:00:00", # <- invalid date
-1 => "1 Jan 2009 00:00:00" # <- invalid ID
}.each do |id, t|
-1 => "1 Jan 2009 00:00:00" }.each do |id, t| # <- invalid
amf_content "getway_old", "/1", [id, t]
post :amf_read
assert_response :success
@ -352,8 +350,7 @@ class AmfControllerTest < ActionController::TestCase
# try to get specific version of non-existent way
[[0, ""],
[0, "1 Jan 1970, 00:00:00"],
[v1.way_id, (v1.timestamp - 10).strftime("%d %b %Y, %H:%M:%S")]
].each do |id, t|
[v1.way_id, (v1.timestamp - 10).strftime("%d %b %Y, %H:%M:%S")]].each do |id, t|
amf_content "getway_old", "/1", [id, t]
post :amf_read
assert_response :success
@ -369,8 +366,7 @@ class AmfControllerTest < ActionController::TestCase
def test_getway_old_invisible
v1 = ways(:invisible_way)
# try to get deleted version
[[v1.way_id, (v1.timestamp + 10).strftime("%d %b %Y, %H:%M:%S")]
].each do |id, t|
[[v1.way_id, (v1.timestamp + 10).strftime("%d %b %Y, %H:%M:%S")]].each do |id, t|
amf_content "getway_old", "/1", [id, t]
post :amf_read
assert_response :success

View file

@ -1181,8 +1181,7 @@ EOF
["<osmChange/>",
"<osmChange></osmChange>",
"<osmChange><modify/></osmChange>",
"<osmChange><modify></modify></osmChange>"
].each do |diff|
"<osmChange><modify></modify></osmChange>"].each do |diff|
# upload it
content diff
post :upload, :id => changesets(:public_user_first_change).id
@ -1598,8 +1597,7 @@ EOF
def test_query_invalid
["abracadabra!",
"1,2,3,F",
";drop table users;"
].each do |bbox|
";drop table users;"].each do |bbox|
get :query, :bbox => bbox
assert_response :bad_request, "'#{bbox}' isn't a bbox"
end
@ -1608,8 +1606,7 @@ EOF
"00-00-00",
";drop table users;",
",",
"-,-"
].each do |time|
"-,-"].each do |time|
get :query, :time => time
assert_response :bad_request, "'#{time}' isn't a valid time range"
end
@ -1617,8 +1614,7 @@ EOF
["me",
"foobar",
"-1",
"0"
].each do |uid|
"0"].each do |uid|
get :query, :user => uid
assert_response :bad_request, "'#{uid}' isn't a valid user ID"
end

View file

@ -607,8 +607,7 @@ class RelationControllerTest < ActionController::TestCase
[current_nodes(:used_node_1),
current_nodes(:used_node_2),
current_ways(:used_way),
current_ways(:way_with_versions)
].each_with_index do |element, _version|
current_ways(:way_with_versions)].each_with_index do |element, _version|
bbox = element.bbox.to_unscaled
check_changeset_modify(bbox) do |changeset_id|
relation_xml = Relation.find(relation_id).to_xml

View file

@ -673,8 +673,7 @@ class WayControllerTest < ActionController::TestCase
# check that the set of IDs match expectations
expected_way_ids = [current_ways(:visible_way).id,
current_ways(:used_way).id
]
current_ways(:used_way).id]
found_way_ids = ways_xml.find("//osm/way").collect { |w| w["id"].to_i }
assert_equal expected_way_ids.sort, found_way_ids.sort,
"expected ways for node #{current_nodes(:used_node_1).id} did not match found"

View file

@ -61,8 +61,7 @@ class MessageTest < ActiveSupport::TestCase
"\xC2\xC2", # 2-byte multibyte identifier, followed by another one
"\x4a\x82", # plain ASCII, followed by multibyte continuation
"\x82\x82", # multibyte continuations without multibyte identifier
"\xe1\x82\x4a", # three-byte identifier, contination and (incorrectly) plain ASCII
]
"\xe1\x82\x4a"] # three-byte identifier, contination and (incorrectly) plain ASCII
invalid_sequences.each do |char|
begin
# create a message and save to the database