Commit 914cd9ee authored by charlie ablett's avatar charlie ablett

Merge branch '209918-enable-chain-alloc-cop' into 'master'

Enable Performance/ChainArrayAllocation cop for import/export module

Closes #209918

See merge request gitlab-org/gitlab!27799
parents fd7c50bc fd85038e
......@@ -380,6 +380,13 @@ Cop/BanCatchThrow:
Performance/ReadlinesEach:
Enabled: true
Performance/ChainArrayAllocation:
Enabled: true
Include:
- 'lib/gitlab/import_export/**/*'
- 'ee/lib/gitlab/import_export/**/*'
- 'ee/lib/ee/gitlab/import_export/**/*'
# https://gitlab.com/gitlab-org/gitlab/-/issues/212541
RSpec/RepeatedExample:
Exclude:
......
......@@ -38,7 +38,7 @@ module Gitlab
def resolve_preloads(model_key, model_tree)
model_tree
.map { |submodel_key, submodel_tree| resolve_preload(model_key, submodel_key, submodel_tree) }
.compact
.tap { |entries| entries.compact! }
.to_h
.deep_merge(@preloads[model_key].to_h)
.presence
......
......@@ -100,7 +100,7 @@ module Gitlab
includes
.map(&method(:serialize_include_definition))
.compact
.tap { |entries| entries.compact! }
.to_h
end
......
......@@ -142,9 +142,9 @@ module Gitlab
end
def build_relations(relation_key, relation_definition, data_hashes)
data_hashes.map do |data_hash|
build_relation(relation_key, relation_definition, data_hash)
end.compact
data_hashes
.map { |data_hash| build_relation(relation_key, relation_definition, data_hash) }
.tap { |entries| entries.compact! }
end
def build_relation(relation_key, relation_definition, data_hash)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment