From dbf8c1d921ce227d8fde88b62113a17fc8fe778d Mon Sep 17 00:00:00 2001 From: Go MAEDA Date: Wed, 11 Jan 2023 13:30:25 +0000 Subject: [PATCH] Fix RuboCop offense Performance/RedundantEqualityComparisonBlock (#38146). git-svn-id: https://svn.redmine.org/redmine/trunk@22031 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- .rubocop_todo.yml | 8 -------- app/models/query.rb | 2 +- app/models/setting.rb | 2 +- lib/redmine/field_format.rb | 2 +- test/integration/api_test/issues_test.rb | 2 +- 5 files changed, 4 insertions(+), 12 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index afb26d8a8..87e78d17d 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -486,14 +486,6 @@ Naming/VariableNumber: - 'test/unit/lib/redmine/scm/adapters/mercurial_adapter_test.rb' - 'test/unit/project_test.rb' -# This cop supports unsafe autocorrection (--autocorrect-all). -Performance/RedundantEqualityComparisonBlock: - Exclude: - - 'app/models/query.rb' - - 'app/models/setting.rb' - - 'lib/redmine/field_format.rb' - - 'test/integration/api_test/issues_test.rb' - # This cop supports safe autocorrection (--autocorrect). Performance/RedundantMatch: Exclude: diff --git a/app/models/query.rb b/app/models/query.rb index 8603d1879..e25824bd0 100644 --- a/app/models/query.rb +++ b/app/models/query.rb @@ -846,7 +846,7 @@ class Query < ActiveRecord::Base end def has_custom_field_column? - columns.any? {|column| column.is_a? QueryCustomFieldColumn} + columns.any?(QueryCustomFieldColumn) end def has_default_columns? diff --git a/app/models/setting.rb b/app/models/setting.rb index fe11dc5f4..3e3476330 100644 --- a/app/models/setting.rb +++ b/app/models/setting.rb @@ -217,7 +217,7 @@ class Setting < ActiveRecord::Base # # => [{'keywords => 'fixes', 'status_id' => "3"}, {'keywords => 'closes', 'status_id' => "5", 'done_ratio' => "100"}] def self.commit_update_keywords_from_params(params) s = [] - if params.is_a?(Hash) && params.key?(:keywords) && params.values.all? {|v| v.is_a? Array} + if params.is_a?(Hash) && params.key?(:keywords) && params.values.all?(Array) attributes = params.except(:keywords).keys params[:keywords].each_with_index do |keywords, i| next if keywords.blank? diff --git a/lib/redmine/field_format.rb b/lib/redmine/field_format.rb index 789a1f9ae..55800dd6b 100644 --- a/lib/redmine/field_format.rb +++ b/lib/redmine/field_format.rb @@ -973,7 +973,7 @@ module Redmine attachment_present = true value = value.except(:blank) - if value.values.any? && value.values.all? {|v| v.is_a?(Hash)} + if value.values.any? && value.values.all?(Hash) value = value.values.first end diff --git a/test/integration/api_test/issues_test.rb b/test/integration/api_test/issues_test.rb index 425343c23..c5f0d3496 100644 --- a/test/integration/api_test/issues_test.rb +++ b/test/integration/api_test/issues_test.rb @@ -231,7 +231,7 @@ class Redmine::ApiTest::IssuesTest < Redmine::ApiTest::Base json = ActiveSupport::JSON.decode(response.body) status_ids_used = json['issues'].collect {|j| j['status']['id']} assert_equal 3, status_ids_used.length - assert status_ids_used.all? {|id| id == 5} + assert status_ids_used.all?(5) end test "GET /issues/:id.xml with journals" do -- 2.39.5