Fix most auto-correctable rubocop issues
This commit is contained in:
parent
34e3e51456
commit
ef7f3d800c
206 changed files with 2925 additions and 3473 deletions
|
@ -5,9 +5,9 @@ class ShortLinkTest < ActiveSupport::TestCase
|
|||
# tests that encoding and decoding are working to within
|
||||
# the acceptable quantisation range.
|
||||
def test_encode_decode
|
||||
cases = Array.new
|
||||
cases = []
|
||||
1000.times do
|
||||
cases << [ 180.0 * rand - 90.0, 360.0 * rand - 180.0, (18 * rand).to_i ]
|
||||
cases << [180.0 * rand - 90.0, 360.0 * rand - 180.0, (18 * rand).to_i]
|
||||
end
|
||||
|
||||
cases.each do |lat, lon, zoom|
|
||||
|
@ -18,7 +18,7 @@ class ShortLinkTest < ActiveSupport::TestCase
|
|||
# one pixel (i.e: zoom + 8). the sqrt(5) is because each position
|
||||
# has an extra bit of accuracy in the lat coordinate, due to the
|
||||
# smaller range.
|
||||
distance = Math.sqrt((lat - lat2) ** 2 + (lon - lon2) ** 2)
|
||||
distance = Math.sqrt((lat - lat2)**2 + (lon - lon2)**2)
|
||||
max_distance = 360.0 / (1 << (zoom + 8)) * 0.5 * Math.sqrt(5)
|
||||
assert max_distance > distance, "Maximum expected error exceeded: #{max_distance} <= #{distance} for (#{lat}, #{lon}, #{zoom})."
|
||||
end
|
||||
|
@ -35,7 +35,7 @@ class ShortLinkTest < ActiveSupport::TestCase
|
|||
|
||||
cases.each do |new_code, old_code|
|
||||
assert_equal ShortLink.decode(old_code), ShortLink.decode(new_code),
|
||||
"old (#{old_code}) and new (#{new_code}) should decode to the same location."
|
||||
"old (#{old_code}) and new (#{new_code}) should decode to the same location."
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue