Fix RuboCop offense Performance/RedundantEqualityComparisonBlock (#38146).

git-svn-id: https://svn.redmine.org/redmine/trunk@22031 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Go MAEDA
2023-01-11 13:30:25 +00:00
parent 1d3a76580f
commit dbf8c1d921
5 changed files with 4 additions and 12 deletions

View File

@@ -486,14 +486,6 @@ Naming/VariableNumber:
- 'test/unit/lib/redmine/scm/adapters/mercurial_adapter_test.rb' - 'test/unit/lib/redmine/scm/adapters/mercurial_adapter_test.rb'
- 'test/unit/project_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). # This cop supports safe autocorrection (--autocorrect).
Performance/RedundantMatch: Performance/RedundantMatch:
Exclude: Exclude:

View File

@@ -846,7 +846,7 @@ class Query < ActiveRecord::Base
end end
def has_custom_field_column? def has_custom_field_column?
columns.any? {|column| column.is_a? QueryCustomFieldColumn} columns.any?(QueryCustomFieldColumn)
end end
def has_default_columns? def has_default_columns?

View File

@@ -217,7 +217,7 @@ class Setting < ActiveRecord::Base
# # => [{'keywords => 'fixes', 'status_id' => "3"}, {'keywords => 'closes', 'status_id' => "5", 'done_ratio' => "100"}] # # => [{'keywords => 'fixes', 'status_id' => "3"}, {'keywords => 'closes', 'status_id' => "5", 'done_ratio' => "100"}]
def self.commit_update_keywords_from_params(params) def self.commit_update_keywords_from_params(params)
s = [] 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 attributes = params.except(:keywords).keys
params[:keywords].each_with_index do |keywords, i| params[:keywords].each_with_index do |keywords, i|
next if keywords.blank? next if keywords.blank?

View File

@@ -973,7 +973,7 @@ module Redmine
attachment_present = true attachment_present = true
value = value.except(:blank) 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 value = value.values.first
end end

View File

@@ -231,7 +231,7 @@ class Redmine::ApiTest::IssuesTest < Redmine::ApiTest::Base
json = ActiveSupport::JSON.decode(response.body) json = ActiveSupport::JSON.decode(response.body)
status_ids_used = json['issues'].collect {|j| j['status']['id']} status_ids_used = json['issues'].collect {|j| j['status']['id']}
assert_equal 3, status_ids_used.length assert_equal 3, status_ids_used.length
assert status_ids_used.all? {|id| id == 5} assert status_ids_used.all?(5)
end end
test "GET /issues/:id.xml with journals" do test "GET /issues/:id.xml with journals" do