Merge branch 'sh-rubocop-reverse-each' into 'master'

Enable Rubocop Performance/ReverseEach

See merge request gitlab-org/gitlab-ce!31120
This commit is contained in:
Douglas Barbosa Alexandre 2019-07-25 00:35:41 +00:00
commit 90b4a8e33f
4 changed files with 3 additions and 11 deletions

View file

@ -262,14 +262,6 @@ Naming/HeredocDelimiterNaming:
Naming/RescuedExceptionsVariableName: Naming/RescuedExceptionsVariableName:
Enabled: false Enabled: false
# Offense count: 3
# Cop supports --auto-correct.
Performance/ReverseEach:
Exclude:
- 'app/models/commit.rb'
- 'db/migrate/20190222051615_add_indexes_for_merge_request_diffs_query.rb'
- 'lib/gitlab/profiler.rb'
# Offense count: 7081 # Offense count: 7081
# Configuration parameters: Prefixes. # Configuration parameters: Prefixes.
# Prefixes: when, with, without # Prefixes: when, with, without

View file

@ -346,7 +346,7 @@ class Commit
if commits_in_merge_request.present? if commits_in_merge_request.present?
message_body << "" message_body << ""
commits_in_merge_request.reverse.each do |commit_in_merge| commits_in_merge_request.reverse_each do |commit_in_merge|
message_body << "#{commit_in_merge.short_id} #{commit_in_merge.title}" message_body << "#{commit_in_merge.short_id} #{commit_in_merge.title}"
end end
end end

View file

@ -35,7 +35,7 @@ class AddIndexesForMergeRequestDiffsQuery < ActiveRecord::Migration[5.0]
end end
def down def down
INDEX_SPECS.reverse.each do |spec| INDEX_SPECS.reverse_each do |spec|
remove_concurrent_index(*spec) remove_concurrent_index(*spec)
end end
end end

View file

@ -166,7 +166,7 @@ module Gitlab
[model, times.count, times.sum] [model, times.count, times.sum]
end end
summarised_load_times.sort_by(&:last).reverse.each do |(model, query_count, time)| summarised_load_times.sort_by(&:last).reverse_each do |(model, query_count, time)|
logger.info("#{model} total (#{query_count}): #{time.round(2)}ms") logger.info("#{model} total (#{query_count}): #{time.round(2)}ms")
end end
end end