Commit fd85038e authored by Matthias Kaeppler's avatar Matthias Kaeppler

Enable Performance/ChainArrayAllocation cop

But only for the `import_export` module for now, where we know
this has been a problem before.

Also fixed the 3 problems it found.
parent 97cf5659
......@@ -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