From ef856653ac19f037dbbcfbd2ade7516b249726ef Mon Sep 17 00:00:00 2001 From: Go MAEDA Date: Tue, 3 Sep 2019 07:42:05 +0000 Subject: Code cleanup: RuboCop: Fix Performance/InefficientHashSearch git-svn-id: http://svn.redmine.org/redmine/trunk@18423 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- .rubocop_todo.yml | 9 --------- test/functional/issues_custom_fields_visibility_test.rb | 2 +- test/functional/search_custom_fields_visibility_test.rb | 2 +- test/functional/timelog_custom_fields_visibility_test.rb | 2 +- test/unit/lib/redmine/mime_type_test.rb | 2 +- test/unit/query_test.rb | 4 ++-- 6 files changed, 6 insertions(+), 15 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 59fce6754..1044133a4 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -815,15 +815,6 @@ Performance/FixedSize: - 'test/integration/api_test/issues_test.rb' - 'test/integration/attachments_test.rb' -# Cop supports --auto-correct. -Performance/InefficientHashSearch: - Exclude: - - 'test/functional/issues_custom_fields_visibility_test.rb' - - 'test/functional/search_custom_fields_visibility_test.rb' - - 'test/functional/timelog_custom_fields_visibility_test.rb' - - 'test/unit/lib/redmine/mime_type_test.rb' - - 'test/unit/query_test.rb' - # Cop supports --auto-correct. Performance/RedundantBlockCall: Exclude: diff --git a/test/functional/issues_custom_fields_visibility_test.rb b/test/functional/issues_custom_fields_visibility_test.rb index 145eb2c4c..d9adcddb1 100644 --- a/test/functional/issues_custom_fields_visibility_test.rb +++ b/test/functional/issues_custom_fields_visibility_test.rb @@ -63,7 +63,7 @@ class IssuesCustomFieldsVisibilityTest < Redmine::ControllerTest } Member.where(:project_id => 1).each do |member| - member.destroy unless @users_to_test.keys.include?(member.principal) + member.destroy unless @users_to_test.key?(member.principal) end end diff --git a/test/functional/search_custom_fields_visibility_test.rb b/test/functional/search_custom_fields_visibility_test.rb index f3c1f91bb..9d9da1721 100644 --- a/test/functional/search_custom_fields_visibility_test.rb +++ b/test/functional/search_custom_fields_visibility_test.rb @@ -59,7 +59,7 @@ class SearchCustomFieldsVisibilityTest < Redmine::ControllerTest } Member.where(:project_id => 1).each do |member| - member.destroy unless @users_to_test.keys.include?(member.principal) + member.destroy unless @users_to_test.key?(member.principal) end end diff --git a/test/functional/timelog_custom_fields_visibility_test.rb b/test/functional/timelog_custom_fields_visibility_test.rb index 604dd36c7..fc23ff3fd 100644 --- a/test/functional/timelog_custom_fields_visibility_test.rb +++ b/test/functional/timelog_custom_fields_visibility_test.rb @@ -153,7 +153,7 @@ class TimelogCustomFieldsVisibilityTest < Redmine::ControllerTest } Member.where(:project_id => 1).each do |member| - member.destroy unless @users_to_test.keys.include?(member.principal) + member.destroy unless @users_to_test.key?(member.principal) end end end diff --git a/test/unit/lib/redmine/mime_type_test.rb b/test/unit/lib/redmine/mime_type_test.rb index 12937d3ed..af5ef768a 100644 --- a/test/unit/lib/redmine/mime_type_test.rb +++ b/test/unit/lib/redmine/mime_type_test.rb @@ -75,7 +75,7 @@ class Redmine::MimeTypeTest < ActiveSupport::TestCase end def test_should_default_to_mime_type_gem - assert !Redmine::MimeType::EXTENSIONS.keys.include?("zip") + assert !Redmine::MimeType::EXTENSIONS.key?("zip") assert_equal "application/zip", Redmine::MimeType.of("file.zip") end end diff --git a/test/unit/query_test.rb b/test/unit/query_test.rb index 2a2a2e99c..792ab60cf 100644 --- a/test/unit/query_test.rb +++ b/test/unit/query_test.rb @@ -2019,7 +2019,7 @@ class QueryTest < ActiveSupport::TestCase test "#available_filters should include 'member_of_group' filter" do query = IssueQuery.new - assert query.available_filters.keys.include?("member_of_group") + assert query.available_filters.key?("member_of_group") assert_equal :list_optional, query.available_filters["member_of_group"][:type] assert query.available_filters["member_of_group"][:values].present? assert_equal Group.givable.sort.map {|g| [g.name, g.id.to_s]}, @@ -2028,7 +2028,7 @@ class QueryTest < ActiveSupport::TestCase test "#available_filters should include 'assigned_to_role' filter" do query = IssueQuery.new - assert query.available_filters.keys.include?("assigned_to_role") + assert query.available_filters.key?("assigned_to_role") assert_equal :list_optional, query.available_filters["assigned_to_role"][:type] assert query.available_filters["assigned_to_role"][:values].include?(['Manager','1']) -- cgit v1.2.3