From 8cb8488127e6ebfed64f6196da14075cbfd29cbc Mon Sep 17 00:00:00 2001 From: Stephen Chudleigh Date: Wed, 18 Dec 2024 13:57:44 -0600 Subject: [PATCH] cognitive complexity --- app/models/evaluation_form.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/models/evaluation_form.rb b/app/models/evaluation_form.rb index d6785469..5a6c8a2d 100644 --- a/app/models/evaluation_form.rb +++ b/app/models/evaluation_form.rb @@ -64,12 +64,12 @@ def find_duplicate_titles end def add_criteria_title_errors(duplicate_titles) - evaluation_criteria.reject(&:marked_for_destruction?).each do |criterion| - next unless duplicate_titles.include?(criterion.title) - next if criterion.errors.added?(:title, I18n.t("evaluation_criteria.duplicate_title_error")) + criteria = evaluation_criteria. + reject(&:marked_for_destruction?). + select{|c| duplicate_titles.include?(c.title)}. + reject{|c| c.errors.added?(:title, I18n.t("evaluation_criteria.duplicate_title_error"))} - criterion.errors.add(:title, I18n.t("evaluation_criteria.duplicate_title_error")) - end + criteria.each {|c| c.errors.add(:title, I18n.t("evaluation_criteria.duplicate_title_error")) } errors.add(:base, I18n.t("evaluation_criterion_unique_title_in_form_error")) end