]> git.openstreetmap.org Git - rails.git/commitdiff
Fix new rubocop warnings
authorTom Hughes <tom@compton.nu>
Mon, 18 Jun 2018 08:00:49 +0000 (09:00 +0100)
committerTom Hughes <tom@compton.nu>
Mon, 18 Jun 2018 08:00:49 +0000 (09:00 +0100)
18 files changed:
app/controllers/amf_controller.rb
lib/classic_pagination/pagination.rb
test/controllers/amf_controller_test.rb
test/controllers/changeset_controller_test.rb
test/helpers/title_helper_test.rb
test/lib/bounding_box_test.rb
test/models/changeset_comment_test.rb
test/models/changeset_tag_test.rb
test/models/client_application_test.rb
test/models/node_tag_test.rb
test/models/note_comment_test.rb
test/models/note_test.rb
test/models/old_node_tag_test.rb
test/models/old_relation_tag_test.rb
test/models/old_way_tag_test.rb
test/models/relation_tag_test.rb
test/models/user_test.rb
test/models/way_tag_test.rb

index 495a658b46224dfd89c4c2a6aea0989cf60a149e..07e7669b173c4037453bac9bb07fabd718be0b5e 100644 (file)
@@ -672,7 +672,7 @@ class AmfController < ApplicationController
         # -- Save revised way
 
         pointlist.collect! do |a|
         # -- Save revised way
 
         pointlist.collect! do |a|
-          renumberednodes[a] ? renumberednodes[a] : a
+          renumberednodes[a] || a
         end
         new_way = Way.new
         new_way.tags = attributes
         end
         new_way = Way.new
         new_way.tags = attributes
@@ -938,7 +938,7 @@ class AmfController < ApplicationController
       INNER JOIN current_relation_members crm ON crm.id=cr.id
       INNER JOIN current_nodes cn ON crm.member_id=cn.id AND crm.member_type='Node'
        WHERE #{OSM.sql_for_area(bbox, 'cn.')}
       INNER JOIN current_relation_members crm ON crm.id=cr.id
       INNER JOIN current_nodes cn ON crm.member_id=cn.id AND crm.member_type='Node'
        WHERE #{OSM.sql_for_area(bbox, 'cn.')}
-      SQL
+    SQL
     unless way_ids.empty?
       sql += <<-SQL
        UNION
     unless way_ids.empty?
       sql += <<-SQL
        UNION
@@ -947,7 +947,7 @@ class AmfController < ApplicationController
         INNER JOIN current_relation_members crm ON crm.id=cr.id
          WHERE crm.member_type='Way'
          AND crm.member_id IN (#{way_ids.join(',')})
         INNER JOIN current_relation_members crm ON crm.id=cr.id
          WHERE crm.member_type='Way'
          AND crm.member_id IN (#{way_ids.join(',')})
-        SQL
+      SQL
     end
     ActiveRecord::Base.connection.select_all(sql).collect { |a| [a["relid"].to_i, a["version"].to_i] }
   end
     end
     ActiveRecord::Base.connection.select_all(sql).collect { |a| [a["relid"].to_i, a["version"].to_i] }
   end
index bd495cef1a568db8374967c80b061523d36c615d..328237d52b35ef3222b4656a6496b70deb0d376c 100644 (file)
@@ -154,6 +154,8 @@ module ActionController
       end
     end
 
       end
     end
 
+    protected
+
     def create_paginators_and_retrieve_collections #:nodoc:
       Pagination::OPTIONS[self.class].each do |collection_id, options|
         next if options[:actions] && !options[:actions].include?(action_name)
     def create_paginators_and_retrieve_collections #:nodoc:
       Pagination::OPTIONS[self.class].each do |collection_id, options|
         next if options[:actions] && !options[:actions].include?(action_name)
@@ -200,9 +202,7 @@ module ActionController
       collection.offset(paginator.current.offset).limit(options[:per_page])
     end
 
       collection.offset(paginator.current.offset).limit(options[:per_page])
     end
 
-    protected :create_paginators_and_retrieve_collections,
-              :count_collection_for_pagination,
-              :find_collection_for_pagination
+    private
 
     def paginator_and_collection_for(_collection_id, options) #:nodoc:
       klass = options[:class_name].constantize
 
     def paginator_and_collection_for(_collection_id, options) #:nodoc:
       klass = options[:class_name].constantize
@@ -214,8 +214,6 @@ module ActionController
       [paginator, collection]
     end
 
       [paginator, collection]
     end
 
-    private :paginator_and_collection_for
-
     # A class representing a paginator for an Active Record collection.
     class Paginator
       include Enumerable
     # A class representing a paginator for an Active Record collection.
     class Paginator
       include Enumerable
index bd7a518843ef8237fa6140773e199e2fa0f92818..5d7e1b778c5e1b950d12535928e7d1fc64dd3b34 100644 (file)
@@ -215,8 +215,8 @@ class AmfControllerTest < ActionController::TestCase
     ways = map[2].collect { |x| x[0] }
     assert ways.include?(way.id),
            "map should include used way"
     ways = map[2].collect { |x| x[0] }
     assert ways.include?(way.id),
            "map should include used way"
-    assert !ways.include?(deleted_way.id),
-           "map should not include deleted way"
+    assert_not ways.include?(deleted_way.id),
+               "map should not include deleted way"
   end
 
   ##
   end
 
   ##
@@ -278,8 +278,8 @@ class AmfControllerTest < ActionController::TestCase
     assert_equal Array, map[2].class, "third map element should be an array"
     # TODO: looks like amf_controller changed since this test was written
     # so someone who knows what they're doing should check this!
     assert_equal Array, map[2].class, "third map element should be an array"
     # TODO: looks like amf_controller changed since this test was written
     # so someone who knows what they're doing should check this!
-    assert !map[2].include?(way.id),
-           "map should not include visible way"
+    assert_not map[2].include?(way.id),
+               "map should not include visible way"
     assert map[2].include?(deleted_way.id),
            "map should include deleted way"
   end
     assert map[2].include?(deleted_way.id),
            "map should include deleted way"
   end
index e8fde7c92cd73594852716c26733945f5d116b8a..575eed765d8f8ba2c46aa9d6e556a06fef5b3a0e 100644 (file)
@@ -244,8 +244,8 @@ class ChangesetControllerTest < ActionController::TestCase
 
     # test that it really is closed now
     cs = Changeset.find(cs_id)
 
     # test that it really is closed now
     cs = Changeset.find(cs_id)
-    assert(!cs.is_open?,
-           "changeset should be closed now (#{cs.closed_at} > #{Time.now.getutc}.")
+    assert_not(cs.is_open?,
+               "changeset should be closed now (#{cs.closed_at} > #{Time.now.getutc}.")
   end
 
   ##
   end
 
   ##
@@ -1875,9 +1875,9 @@ CHANGESET
     assert_equal Changeset::MAX_ELEMENTS + 1, changeset.num_changes
 
     # check that the changeset is now closed as well
     assert_equal Changeset::MAX_ELEMENTS + 1, changeset.num_changes
 
     # check that the changeset is now closed as well
-    assert(!changeset.is_open?,
-           "changeset should have been auto-closed by exceeding " \
-           "element limit.")
+    assert_not(changeset.is_open?,
+               "changeset should have been auto-closed by exceeding " \
+               "element limit.")
   end
 
   ##
   end
 
   ##
index c30f793d3f603f079da6199ac9ddd531b1bd4dd2..1c26a7220d5f8eba9cdc063e37a74cd4c46e9b7c 100644 (file)
@@ -1,4 +1,3 @@
-
 require "test_helper"
 
 class TitleHelperTest < ActionView::TestCase
 require "test_helper"
 
 class TitleHelperTest < ActionView::TestCase
index 3e0c5490b330a398e749714b3c77cd237d1c55b7..46ff38c9ade19cd597cb0d08b4a9a135f9022a33 100644 (file)
@@ -222,7 +222,7 @@ class BoundingBoxTest < ActiveSupport::TestCase
   end
 
   def test_complete
   end
 
   def test_complete
-    assert !@bbox_from_nils.complete?, "should contain a nil"
+    assert_not @bbox_from_nils.complete?, "should contain a nil"
     assert @bbox_from_string.complete?, "should not contain a nil"
   end
 
     assert @bbox_from_string.complete?, "should not contain a nil"
   end
 
index 58fdb9e75d6557a15652972396ec09eadba2f0b2..b620dc8e7e805f5f822d8921c17d870a93f42384 100644 (file)
@@ -50,7 +50,7 @@ class ChangesetCommentTest < ActiveSupport::TestCase
     bad.each do |body|
       changeset_comment = create(:changeset_comment)
       changeset_comment.body = body
     bad.each do |body|
       changeset_comment = create(:changeset_comment)
       changeset_comment.body = body
-      assert !changeset_comment.valid?, "#{body} is valid when it shouldn't be"
+      assert_not changeset_comment.valid?, "#{body} is valid when it shouldn't be"
     end
   end
 end
     end
   end
 end
index 2788d6f2d01c3884d8d382c991207d42ff5341c4..1db2effd65aecf20c3588a93ef88a1525eaef722 100644 (file)
@@ -33,7 +33,7 @@ class ChangesetTagTest < ActiveSupport::TestCase
       tag.changeset_id = 1
       tag.k = k
       tag.v = "v"
       tag.changeset_id = 1
       tag.k = k
       tag.v = "v"
-      assert !tag.valid?, "Key #{k} should be too long"
+      assert_not tag.valid?, "Key #{k} should be too long"
       assert tag.errors[:k].any?
     end
   end
       assert tag.errors[:k].any?
     end
   end
@@ -44,14 +44,14 @@ class ChangesetTagTest < ActiveSupport::TestCase
       tag.changeset_id = 1
       tag.k = "k"
       tag.v = v
       tag.changeset_id = 1
       tag.k = "k"
       tag.v = v
-      assert !tag.valid?, "Value #{v} should be too long"
+      assert_not tag.valid?, "Value #{v} should be too long"
       assert tag.errors[:v].any?
     end
   end
 
   def test_empty_tag_invalid
     tag = ChangesetTag.new
       assert tag.errors[:v].any?
     end
   end
 
   def test_empty_tag_invalid
     tag = ChangesetTag.new
-    assert !tag.valid?, "Empty tag should be invalid"
+    assert_not tag.valid?, "Empty tag should be invalid"
     assert tag.errors[:changeset].any?
   end
 
     assert tag.errors[:changeset].any?
   end
 
index 9684513c42e74ae400b14447fb296049f6d584c6..8e5b21aff7c55500b376644bf7db16218e03fe03 100644 (file)
@@ -14,7 +14,7 @@ class ClientApplicationTest < ActiveSupport::TestCase
     bad.each do |url|
       app = build(:client_application)
       app.url = url
     bad.each do |url|
       app = build(:client_application)
       app.url = url
-      assert !app.valid?, "#{url} is valid when it shouldn't be"
+      assert_not app.valid?, "#{url} is valid when it shouldn't be"
     end
   end
 
     end
   end
 
@@ -31,7 +31,7 @@ class ClientApplicationTest < ActiveSupport::TestCase
     bad.each do |url|
       app = build(:client_application)
       app.support_url = url
     bad.each do |url|
       app = build(:client_application)
       app.support_url = url
-      assert !app.valid?, "#{url} is valid when it shouldn't be"
+      assert_not app.valid?, "#{url} is valid when it shouldn't be"
     end
   end
 
     end
   end
 
@@ -48,7 +48,7 @@ class ClientApplicationTest < ActiveSupport::TestCase
     bad.each do |url|
       app = build(:client_application)
       app.callback_url = url
     bad.each do |url|
       app = build(:client_application)
       app.callback_url = url
-      assert !app.valid?, "#{url} is valid when it shouldn't be"
+      assert_not app.valid?, "#{url} is valid when it shouldn't be"
     end
   end
 end
     end
   end
 end
index 57a5f0d43457d5db7bb7a3ab30e18a27f4a7e9d1..1a7125f08b7f6ac8be14637313837118bc156f30 100644 (file)
@@ -20,20 +20,20 @@ class NodeTagTest < ActiveSupport::TestCase
   def test_length_key_invalid
     tag = create(:node_tag)
     tag.k = "k" * 256
   def test_length_key_invalid
     tag = create(:node_tag)
     tag.k = "k" * 256
-    assert !tag.valid?, "Key should be too long"
+    assert_not tag.valid?, "Key should be too long"
     assert tag.errors[:k].any?
   end
 
   def test_length_value_invalid
     tag = create(:node_tag)
     tag.v = "v" * 256
     assert tag.errors[:k].any?
   end
 
   def test_length_value_invalid
     tag = create(:node_tag)
     tag.v = "v" * 256
-    assert !tag.valid?, "Value should be too long"
+    assert_not tag.valid?, "Value should be too long"
     assert tag.errors[:v].any?
   end
 
   def test_empty_node_tag_invalid
     tag = NodeTag.new
     assert tag.errors[:v].any?
   end
 
   def test_empty_node_tag_invalid
     tag = NodeTag.new
-    assert !tag.valid?, "Empty tag should be invalid"
+    assert_not tag.valid?, "Empty tag should be invalid"
     assert tag.errors[:node].any?
   end
 
     assert tag.errors[:node].any?
   end
 
index 21d67dc678718afd4171de3be2985664e556084c..bfedcf12592730f18947552ddf5022ff3b0048de 100644 (file)
@@ -14,7 +14,7 @@ class NoteCommentTest < ActiveSupport::TestCase
     bad.each do |event|
       note_comment = create(:note_comment)
       note_comment.event = event
     bad.each do |event|
       note_comment = create(:note_comment)
       note_comment.event = event
-      assert !note_comment.valid?, "#{event} is valid when it shouldn't be"
+      assert_not note_comment.valid?, "#{event} is valid when it shouldn't be"
     end
   end
 
     end
   end
 
@@ -33,7 +33,7 @@ class NoteCommentTest < ActiveSupport::TestCase
     bad.each do |body|
       note_comment = create(:note_comment)
       note_comment.body = body
     bad.each do |body|
       note_comment = create(:note_comment)
       note_comment.body = body
-      assert !note_comment.valid?, "#{body} is valid when it shouldn't be"
+      assert_not note_comment.valid?, "#{body} is valid when it shouldn't be"
     end
   end
 end
     end
   end
 end
index 369ff10832d66ff2febdfea93915add5c55b6823..2010fe20204047f4a4f78eaea9387ba5ff8fc762 100644 (file)
@@ -14,7 +14,7 @@ class NoteTest < ActiveSupport::TestCase
     bad.each do |status|
       note = create(:note)
       note.status = status
     bad.each do |status|
       note = create(:note)
       note.status = status
-      assert !note.valid?, "#{status} is valid when it shouldn't be"
+      assert_not note.valid?, "#{status} is valid when it shouldn't be"
     end
   end
 
     end
   end
 
index 33871657eda4052e73bbff804e6cf8d52a95b055..f432d04b85c2fd8d680835133ee54d7a050eb075 100644 (file)
@@ -27,13 +27,13 @@ class OldNodeTagTest < ActiveSupport::TestCase
   def test_length_value_invalid
     tag = create(:old_node_tag)
     tag.v = "v" * 256
   def test_length_value_invalid
     tag = create(:old_node_tag)
     tag.v = "v" * 256
-    assert !tag.valid?, "Value should be too long"
+    assert_not tag.valid?, "Value should be too long"
     assert tag.errors[:v].any?
   end
 
   def test_empty_tag_invalid
     tag = OldNodeTag.new
     assert tag.errors[:v].any?
   end
 
   def test_empty_tag_invalid
     tag = OldNodeTag.new
-    assert !tag.valid?, "Empty tag should be invalid"
+    assert_not tag.valid?, "Empty tag should be invalid"
     assert tag.errors[:old_node].any?
   end
 
     assert tag.errors[:old_node].any?
   end
 
index d9dae24732174e955e1f20d1760667ebbe40bb80..a05e67ee704cb4846389b97c0fa5b07081e5ee23 100644 (file)
@@ -20,20 +20,20 @@ class OldRelationTagTest < ActiveSupport::TestCase
   def test_length_key_invalid
     tag = create(:old_relation_tag)
     tag.k = "k" * 256
   def test_length_key_invalid
     tag = create(:old_relation_tag)
     tag.k = "k" * 256
-    assert !tag.valid?, "Key should be too long"
+    assert_not tag.valid?, "Key should be too long"
     assert tag.errors[:k].any?
   end
 
   def test_length_value_invalid
     tag = create(:old_relation_tag)
     tag.v = "v" * 256
     assert tag.errors[:k].any?
   end
 
   def test_length_value_invalid
     tag = create(:old_relation_tag)
     tag.v = "v" * 256
-    assert !tag.valid?, "Value should be too long"
+    assert_not tag.valid?, "Value should be too long"
     assert tag.errors[:v].any?
   end
 
   def test_empty_tag_invalid
     tag = OldRelationTag.new
     assert tag.errors[:v].any?
   end
 
   def test_empty_tag_invalid
     tag = OldRelationTag.new
-    assert !tag.valid?, "Empty tag should be invalid"
+    assert_not tag.valid?, "Empty tag should be invalid"
     assert tag.errors[:old_relation].any?
   end
 
     assert tag.errors[:old_relation].any?
   end
 
index b2b6934249fe74095780f89f3e9078c960d8cd88..565633063cc10e59ca1b34202aa188202acb5d97 100644 (file)
@@ -20,20 +20,20 @@ class OldWayTagTest < ActiveSupport::TestCase
   def test_length_key_invalid
     tag = create(:old_way_tag)
     tag.k = "k" * 256
   def test_length_key_invalid
     tag = create(:old_way_tag)
     tag.k = "k" * 256
-    assert !tag.valid?, "Key should be too long"
+    assert_not tag.valid?, "Key should be too long"
     assert tag.errors[:k].any?
   end
 
   def test_length_value_invalid
     tag = create(:old_way_tag)
     tag.v = "v" * 256
     assert tag.errors[:k].any?
   end
 
   def test_length_value_invalid
     tag = create(:old_way_tag)
     tag.v = "v" * 256
-    assert !tag.valid?, "Value should be too long"
+    assert_not tag.valid?, "Value should be too long"
     assert tag.errors[:v].any?
   end
 
   def test_empty_tag_invalid
     tag = OldWayTag.new
     assert tag.errors[:v].any?
   end
 
   def test_empty_tag_invalid
     tag = OldWayTag.new
-    assert !tag.valid?, "Empty tag should be invalid"
+    assert_not tag.valid?, "Empty tag should be invalid"
     assert tag.errors[:old_way].any?
   end
 
     assert tag.errors[:old_way].any?
   end
 
index cf9b24ded95f1361af86799709548aef09d84bcb..e81b8b49c26eeeb018abb019f686b374f476e5c3 100644 (file)
@@ -20,20 +20,20 @@ class RelationTagTest < ActiveSupport::TestCase
   def test_length_key_invalid
     tag = create(:relation_tag)
     tag.k = "k" * 256
   def test_length_key_invalid
     tag = create(:relation_tag)
     tag.k = "k" * 256
-    assert !tag.valid?, "Key should be too long"
+    assert_not tag.valid?, "Key should be too long"
     assert tag.errors[:k].any?
   end
 
   def test_length_value_invalid
     tag = create(:relation_tag)
     tag.v = "v" * 256
     assert tag.errors[:k].any?
   end
 
   def test_length_value_invalid
     tag = create(:relation_tag)
     tag.v = "v" * 256
-    assert !tag.valid?, "Value should be too long"
+    assert_not tag.valid?, "Value should be too long"
     assert tag.errors[:v].any?
   end
 
   def test_empty_tag_invalid
     tag = RelationTag.new
     assert tag.errors[:v].any?
   end
 
   def test_empty_tag_invalid
     tag = RelationTag.new
-    assert !tag.valid?, "Empty relation tag should be invalid"
+    assert_not tag.valid?, "Empty relation tag should be invalid"
     assert tag.errors[:relation].any?
   end
 
     assert tag.errors[:relation].any?
   end
 
index 168b9c3fa32672510da6eeb021413b2b6136b96f..0e618cd22c86ec3058c0f699c6dfc1730a307bfc 100644 (file)
@@ -67,7 +67,7 @@ class UserTest < ActiveSupport::TestCase
     user.display_name = "123"
     assert user.valid?, " should allow nil display name"
     user.display_name = "12"
     user.display_name = "123"
     assert user.valid?, " should allow nil display name"
     user.display_name = "12"
-    assert !user.valid?, "should not allow 2 char name"
+    assert_not user.valid?, "should not allow 2 char name"
     user.display_name = ""
     assert_not user.valid?
     user.display_name = nil
     user.display_name = ""
     assert_not user.valid?
     user.display_name = nil
@@ -99,7 +99,7 @@ class UserTest < ActiveSupport::TestCase
     bad.each do |display_name|
       user = build(:user)
       user.display_name = display_name
     bad.each do |display_name|
       user = build(:user)
       user.display_name = display_name
-      assert !user.valid?, "#{display_name} is valid when it shouldn't be"
+      assert_not user.valid?, "#{display_name} is valid when it shouldn't be"
     end
   end
 
     end
   end
 
index a3699cac4e1d311d45ea48f1cb586bb57f24a122..990a4362789d2ccfb57c9c20e7e966886e70a8f5 100644 (file)
@@ -20,20 +20,20 @@ class WayTagTest < ActiveSupport::TestCase
   def test_length_key_invalid
     tag = create(:way_tag)
     tag.k = "k" * 256
   def test_length_key_invalid
     tag = create(:way_tag)
     tag.k = "k" * 256
-    assert !tag.valid?, "Key should be too long"
+    assert_not tag.valid?, "Key should be too long"
     assert tag.errors[:k].any?
   end
 
   def test_length_value_invalid
     tag = create(:way_tag)
     tag.v = "v" * 256
     assert tag.errors[:k].any?
   end
 
   def test_length_value_invalid
     tag = create(:way_tag)
     tag.v = "v" * 256
-    assert !tag.valid?, "Value should be too long"
+    assert_not tag.valid?, "Value should be too long"
     assert tag.errors[:v].any?
   end
 
   def test_empty_tag_invalid
     tag = WayTag.new
     assert tag.errors[:v].any?
   end
 
   def test_empty_tag_invalid
     tag = WayTag.new
-    assert !tag.valid?, "Empty way tag should be invalid"
+    assert_not tag.valid?, "Empty way tag should be invalid"
     assert tag.errors[:way].any?
   end
 
     assert tag.errors[:way].any?
   end