]> git.openstreetmap.org Git - rails.git/commitdiff
Fix rubocop warnings
authorTom Hughes <tom@compton.nu>
Thu, 9 Jun 2016 21:18:28 +0000 (22:18 +0100)
committerTom Hughes <tom@compton.nu>
Thu, 9 Jun 2016 21:18:28 +0000 (22:18 +0100)
app/controllers/api_controller.rb
app/helpers/note_helper.rb
lib/bounding_box.rb
lib/daemons/gpx_import_ctl
test/controllers/amf_controller_test.rb
test/controllers/changeset_controller_test.rb
test/controllers/relation_controller_test.rb
test/controllers/way_controller_test.rb
test/models/message_test.rb

index 25e1e3b95cc9edebaff056d1ea9fdbcf5ca22f98..eb59a8a8df0bda5da97d218ceee62bd99ed4393d 100644 (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
                      []
index 2a101612928db938e68d3ccb51ce946cc467776a..6ebd18345526e186833527454e72895065c36539 100644 (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
 
index 5d8ada1c4973be0b8873cdbc6a05c28b9c52fa7b..9f6c3d9d515184c588f1f8896a39fb7f27253cab 100644 (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.
index 43fb48c1567c894bee6e04e26bf94df0bb24ad14..8b893a6b2780aa1bd0b93876b1890a8d3ce09984 100755 (executable)
@@ -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
index d388114dd99626db7f0f54ff3fa8e07f086e8880..09b88e98f7ab378e7b3d63b10a4632da22bd2678 100644 (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
@@ -329,10 +328,9 @@ class AmfControllerTest < ActionController::TestCase
     way_id = current_ways(:way_with_versions).id
     { "foo"  => "bar",
       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|
+      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" }.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
index 4db952ab9d4d4300e27d9c40cab9b5de4d739987..ecccb1f5f3b1feadbc74e00c055489ccdef32c87 100644 (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
index 854fc51d0b5d14ce434bb51c0448888573a48758..ab0aca45ed1233e97576b737427c0ad9eaa45f1d 100644 (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
index 84846f9233c26df21ca466da4a5b4173bbae14a1..ccf29945579ab1571551ab94aa7362151d5dd5be 100644 (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"
index a6ae3ecce3b0f9e02b0a30ba128624ff2de85ffb..ff9f24da42c71b17ccc9938c0faa271d230ca9b7 100644 (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