From f7a35c5895b1bd830a9bf2c08ce36e265deb3e4c Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Mon, 18 Jun 2018 09:00:49 +0100 Subject: [PATCH] Fix new rubocop warnings --- app/controllers/amf_controller.rb | 6 +++--- lib/classic_pagination/pagination.rb | 8 +++----- test/controllers/amf_controller_test.rb | 8 ++++---- test/controllers/changeset_controller_test.rb | 10 +++++----- test/helpers/title_helper_test.rb | 1 - test/lib/bounding_box_test.rb | 2 +- test/models/changeset_comment_test.rb | 2 +- test/models/changeset_tag_test.rb | 6 +++--- test/models/client_application_test.rb | 6 +++--- test/models/node_tag_test.rb | 6 +++--- test/models/note_comment_test.rb | 4 ++-- test/models/note_test.rb | 2 +- test/models/old_node_tag_test.rb | 4 ++-- test/models/old_relation_tag_test.rb | 6 +++--- test/models/old_way_tag_test.rb | 6 +++--- test/models/relation_tag_test.rb | 6 +++--- test/models/user_test.rb | 4 ++-- test/models/way_tag_test.rb | 6 +++--- 18 files changed, 45 insertions(+), 48 deletions(-) diff --git a/app/controllers/amf_controller.rb b/app/controllers/amf_controller.rb index 495a658b4..07e7669b1 100644 --- a/app/controllers/amf_controller.rb +++ b/app/controllers/amf_controller.rb @@ -672,7 +672,7 @@ class AmfController < ApplicationController # -- Save revised way pointlist.collect! do |a| - renumberednodes[a] ? renumberednodes[a] : a + renumberednodes[a] || a 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.')} - SQL + SQL 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(',')}) - SQL + SQL end ActiveRecord::Base.connection.select_all(sql).collect { |a| [a["relid"].to_i, a["version"].to_i] } end diff --git a/lib/classic_pagination/pagination.rb b/lib/classic_pagination/pagination.rb index bd495cef1..328237d52 100644 --- a/lib/classic_pagination/pagination.rb +++ b/lib/classic_pagination/pagination.rb @@ -154,6 +154,8 @@ module ActionController 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) @@ -200,9 +202,7 @@ module ActionController 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 @@ -214,8 +214,6 @@ module ActionController [paginator, collection] end - private :paginator_and_collection_for - # A class representing a paginator for an Active Record collection. class Paginator include Enumerable diff --git a/test/controllers/amf_controller_test.rb b/test/controllers/amf_controller_test.rb index bd7a51884..5d7e1b778 100644 --- a/test/controllers/amf_controller_test.rb +++ b/test/controllers/amf_controller_test.rb @@ -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" - 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 ## @@ -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 !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 diff --git a/test/controllers/changeset_controller_test.rb b/test/controllers/changeset_controller_test.rb index e8fde7c92..575eed765 100644 --- a/test/controllers/changeset_controller_test.rb +++ b/test/controllers/changeset_controller_test.rb @@ -244,8 +244,8 @@ class ChangesetControllerTest < ActionController::TestCase # 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 ## @@ -1875,9 +1875,9 @@ CHANGESET 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 ## diff --git a/test/helpers/title_helper_test.rb b/test/helpers/title_helper_test.rb index c30f793d3..1c26a7220 100644 --- a/test/helpers/title_helper_test.rb +++ b/test/helpers/title_helper_test.rb @@ -1,4 +1,3 @@ - require "test_helper" class TitleHelperTest < ActionView::TestCase diff --git a/test/lib/bounding_box_test.rb b/test/lib/bounding_box_test.rb index 3e0c5490b..46ff38c9a 100644 --- a/test/lib/bounding_box_test.rb +++ b/test/lib/bounding_box_test.rb @@ -222,7 +222,7 @@ class BoundingBoxTest < ActiveSupport::TestCase 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 diff --git a/test/models/changeset_comment_test.rb b/test/models/changeset_comment_test.rb index 58fdb9e75..b620dc8e7 100644 --- a/test/models/changeset_comment_test.rb +++ b/test/models/changeset_comment_test.rb @@ -50,7 +50,7 @@ class ChangesetCommentTest < ActiveSupport::TestCase 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 diff --git a/test/models/changeset_tag_test.rb b/test/models/changeset_tag_test.rb index 2788d6f2d..1db2effd6 100644 --- a/test/models/changeset_tag_test.rb +++ b/test/models/changeset_tag_test.rb @@ -33,7 +33,7 @@ class ChangesetTagTest < ActiveSupport::TestCase 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 @@ -44,14 +44,14 @@ class ChangesetTagTest < ActiveSupport::TestCase 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.valid?, "Empty tag should be invalid" + assert_not tag.valid?, "Empty tag should be invalid" assert tag.errors[:changeset].any? end diff --git a/test/models/client_application_test.rb b/test/models/client_application_test.rb index 9684513c4..8e5b21aff 100644 --- a/test/models/client_application_test.rb +++ b/test/models/client_application_test.rb @@ -14,7 +14,7 @@ class ClientApplicationTest < ActiveSupport::TestCase 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 @@ -31,7 +31,7 @@ class ClientApplicationTest < ActiveSupport::TestCase 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 @@ -48,7 +48,7 @@ class ClientApplicationTest < ActiveSupport::TestCase 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 diff --git a/test/models/node_tag_test.rb b/test/models/node_tag_test.rb index 57a5f0d43..1a7125f08 100644 --- a/test/models/node_tag_test.rb +++ b/test/models/node_tag_test.rb @@ -20,20 +20,20 @@ class NodeTagTest < ActiveSupport::TestCase 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.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.valid?, "Empty tag should be invalid" + assert_not tag.valid?, "Empty tag should be invalid" assert tag.errors[:node].any? end diff --git a/test/models/note_comment_test.rb b/test/models/note_comment_test.rb index 21d67dc67..bfedcf125 100644 --- a/test/models/note_comment_test.rb +++ b/test/models/note_comment_test.rb @@ -14,7 +14,7 @@ class NoteCommentTest < ActiveSupport::TestCase 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 @@ -33,7 +33,7 @@ class NoteCommentTest < ActiveSupport::TestCase 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 diff --git a/test/models/note_test.rb b/test/models/note_test.rb index 369ff1083..2010fe202 100644 --- a/test/models/note_test.rb +++ b/test/models/note_test.rb @@ -14,7 +14,7 @@ class NoteTest < ActiveSupport::TestCase 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 diff --git a/test/models/old_node_tag_test.rb b/test/models/old_node_tag_test.rb index 33871657e..f432d04b8 100644 --- a/test/models/old_node_tag_test.rb +++ b/test/models/old_node_tag_test.rb @@ -27,13 +27,13 @@ class OldNodeTagTest < ActiveSupport::TestCase 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.valid?, "Empty tag should be invalid" + assert_not tag.valid?, "Empty tag should be invalid" assert tag.errors[:old_node].any? end diff --git a/test/models/old_relation_tag_test.rb b/test/models/old_relation_tag_test.rb index d9dae2473..a05e67ee7 100644 --- a/test/models/old_relation_tag_test.rb +++ b/test/models/old_relation_tag_test.rb @@ -20,20 +20,20 @@ class OldRelationTagTest < ActiveSupport::TestCase 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.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.valid?, "Empty tag should be invalid" + assert_not tag.valid?, "Empty tag should be invalid" assert tag.errors[:old_relation].any? end diff --git a/test/models/old_way_tag_test.rb b/test/models/old_way_tag_test.rb index b2b693424..565633063 100644 --- a/test/models/old_way_tag_test.rb +++ b/test/models/old_way_tag_test.rb @@ -20,20 +20,20 @@ class OldWayTagTest < ActiveSupport::TestCase 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.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.valid?, "Empty tag should be invalid" + assert_not tag.valid?, "Empty tag should be invalid" assert tag.errors[:old_way].any? end diff --git a/test/models/relation_tag_test.rb b/test/models/relation_tag_test.rb index cf9b24ded..e81b8b49c 100644 --- a/test/models/relation_tag_test.rb +++ b/test/models/relation_tag_test.rb @@ -20,20 +20,20 @@ class RelationTagTest < ActiveSupport::TestCase 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.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.valid?, "Empty relation tag should be invalid" + assert_not tag.valid?, "Empty relation tag should be invalid" assert tag.errors[:relation].any? end diff --git a/test/models/user_test.rb b/test/models/user_test.rb index 168b9c3fa..0e618cd22 100644 --- a/test/models/user_test.rb +++ b/test/models/user_test.rb @@ -67,7 +67,7 @@ class UserTest < ActiveSupport::TestCase 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 @@ -99,7 +99,7 @@ class UserTest < ActiveSupport::TestCase 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 diff --git a/test/models/way_tag_test.rb b/test/models/way_tag_test.rb index a3699cac4..990a43627 100644 --- a/test/models/way_tag_test.rb +++ b/test/models/way_tag_test.rb @@ -20,20 +20,20 @@ class WayTagTest < ActiveSupport::TestCase 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.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.valid?, "Empty way tag should be invalid" + assert_not tag.valid?, "Empty way tag should be invalid" assert tag.errors[:way].any? end -- 2.43.2