Skip to content

Commit

Permalink
cognitive complexity
Browse files Browse the repository at this point in the history
  • Loading branch information
stepchud committed Dec 18, 2024
1 parent ad63854 commit 8cb8488
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions app/models/evaluation_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 8cb8488

Please sign in to comment.