Project

General

Profile

Patch #38146 » 0006-Fix-RuboCop-offense-Performance-RedundantEqualityCom.patch

Go MAEDA, 2023-01-04 07:28

View differences:

.rubocop_todo.yml
486 486
    - 'test/unit/lib/redmine/scm/adapters/mercurial_adapter_test.rb'
487 487
    - 'test/unit/project_test.rb'
488 488

  
489
# This cop supports unsafe autocorrection (--autocorrect-all).
490
Performance/RedundantEqualityComparisonBlock:
491
  Exclude:
492
    - 'app/models/query.rb'
493
    - 'app/models/setting.rb'
494
    - 'lib/redmine/field_format.rb'
495
    - 'test/integration/api_test/issues_test.rb'
496

  
497 489
# This cop supports safe autocorrection (--autocorrect).
498 490
Performance/RedundantMatch:
499 491
  Exclude:
app/models/query.rb
846 846
  end
847 847

  
848 848
  def has_custom_field_column?
849
    columns.any? {|column| column.is_a? QueryCustomFieldColumn}
849
    columns.any?(QueryCustomFieldColumn)
850 850
  end
851 851

  
852 852
  def has_default_columns?
app/models/setting.rb
217 217
  # # => [{'keywords => 'fixes', 'status_id' => "3"}, {'keywords => 'closes', 'status_id' => "5", 'done_ratio' => "100"}]
218 218
  def self.commit_update_keywords_from_params(params)
219 219
    s = []
220
    if params.is_a?(Hash) && params.key?(:keywords) && params.values.all? {|v| v.is_a? Array}
220
    if params.is_a?(Hash) && params.key?(:keywords) && params.values.all?(Array)
221 221
      attributes = params.except(:keywords).keys
222 222
      params[:keywords].each_with_index do |keywords, i|
223 223
        next if keywords.blank?
lib/redmine/field_format.rb
973 973
          attachment_present = true
974 974
          value = value.except(:blank)
975 975

  
976
          if value.values.any? && value.values.all? {|v| v.is_a?(Hash)}
976
          if value.values.any? && value.values.all?(Hash)
977 977
            value = value.values.first
978 978
          end
979 979

  
test/integration/api_test/issues_test.rb
231 231
    json = ActiveSupport::JSON.decode(response.body)
232 232
    status_ids_used = json['issues'].collect {|j| j['status']['id']}
233 233
    assert_equal 3, status_ids_used.length
234
    assert status_ids_used.all? {|id| id == 5}
234
    assert status_ids_used.all?(5)
235 235
  end
236 236

  
237 237
  test "GET /issues/:id.xml with journals" do
(5-5/9)