summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlessio Caiazza <acaiazza@gitlab.com>2018-10-26 13:10:11 +0000
committerAlessio Caiazza <acaiazza@gitlab.com>2018-10-26 13:10:11 +0000
commitb058d71c87a7963acdcb253dee0159cfa56b29b5 (patch)
treedac380331ed9f9c285793619afe6853df76750f8
parente2895f69d08b6fb02eac26eb26f21ab842f5ed94 (diff)
downloadgitlab-ce-ac-post-merge-pipeline.tar.gz
Reduce Cognitive Complexity in EnvironmentStatusac-post-merge-pipeline
-rw-r--r--app/models/environment_status.rb14
1 files changed, 7 insertions, 7 deletions
diff --git a/app/models/environment_status.rb b/app/models/environment_status.rb
index 41bd69ac441..a84871f7253 100644
--- a/app/models/environment_status.rb
+++ b/app/models/environment_status.rb
@@ -68,18 +68,18 @@ class EnvironmentStatus
def self.build_environments_status(mr, user, pipeline)
return [] unless pipeline.present?
- find_environments(pipeline) do |environment|
- next unless Ability.allowed?(user, :read_environment, environment)
-
+ find_environments(user, pipeline).map do |environment|
EnvironmentStatus.new(environment, mr, pipeline.sha)
- end.compact
+ end
end
+ private_class_method :build_environments_status
- def self.find_environments(pipeline, &blk)
+ def self.find_environments(user, pipeline)
env_ids = Deployment.where(deployable: pipeline.builds).select(:environment_id)
- Environment.available.where(id: env_ids).map do |environment|
- blk.call(environment)
+ Environment.available.where(id: env_ids).select do |environment|
+ Ability.allowed?(user, :read_environment, environment)
end
end
+ private_class_method :find_environments
end