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: ...@@ -380,6 +380,13 @@ Cop/BanCatchThrow:
Performance/ReadlinesEach: Performance/ReadlinesEach:
Enabled: true 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 # https://gitlab.com/gitlab-org/gitlab/-/issues/212541
RSpec/RepeatedExample: RSpec/RepeatedExample:
Exclude: Exclude:
......
...@@ -38,7 +38,7 @@ module Gitlab ...@@ -38,7 +38,7 @@ module Gitlab
def resolve_preloads(model_key, model_tree) def resolve_preloads(model_key, model_tree)
model_tree model_tree
.map { |submodel_key, submodel_tree| resolve_preload(model_key, submodel_key, submodel_tree) } .map { |submodel_key, submodel_tree| resolve_preload(model_key, submodel_key, submodel_tree) }
.compact .tap { |entries| entries.compact! }
.to_h .to_h
.deep_merge(@preloads[model_key].to_h) .deep_merge(@preloads[model_key].to_h)
.presence .presence
......
...@@ -100,7 +100,7 @@ module Gitlab ...@@ -100,7 +100,7 @@ module Gitlab
includes includes
.map(&method(:serialize_include_definition)) .map(&method(:serialize_include_definition))
.compact .tap { |entries| entries.compact! }
.to_h .to_h
end end
......
...@@ -142,9 +142,9 @@ module Gitlab ...@@ -142,9 +142,9 @@ module Gitlab
end end
def build_relations(relation_key, relation_definition, data_hashes) def build_relations(relation_key, relation_definition, data_hashes)
data_hashes.map do |data_hash| data_hashes
build_relation(relation_key, relation_definition, data_hash) .map { |data_hash| build_relation(relation_key, relation_definition, data_hash) }
end.compact .tap { |entries| entries.compact! }
end end
def build_relation(relation_key, relation_definition, data_hash) 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