OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
[#66093] FIXME: reduce complexity
Tobias Dillmann11a67b0174f3
diff --git a/app/models/acts_as_customizable/calculated_value.rb b/app/models/acts_as_customizable/calculated_value.rbindex babbcdbaf7a..895496794ae 100644--- a/app/models/acts_as_customizable/calculated_value.rb+++ b/app/models/acts_as_customizable/calculated_value.rb@@ -88,6 +88,7 @@ module ActsAsCustomizable::CalculatedValuecf_id.sub("cf_", "").to_iend+ # FIXME: refactor this method to reduce complexitydef refresh_calculation_errors!(given_cfs, enabled_ids, calculated_fields, result)return unless is_a?(Project)@@ -105,12 +106,13 @@ module ActsAsCustomizable::CalculatedValue# 1. The value of a referenced custom field is missing (nil)cvs_with_errors.concat(create_errors_for_missing_attributes(given_cfs, calculated_fields))- # 2. A referenced custom field disabled (not present in the enabled_ids list)+ # 2. A referenced custom field is disabled (not present in the enabled_ids list)unsuccessful_cvs = calculated_fields.filter { unsuccessfully_calculated_cfs.include?(it.id) }disabled_errors = create_errors_for_disabled_attributes(unsuccessful_cvs, enabled_ids)cvs_with_errors.concat(disabled_errors)end+ # For missing calculation results without obvious other errors, we create a generic mathematical error.unsuccessfully_calculated_cfs.each do |cf_id|next if cvs_with_errors.include?(cf_id)@@ -122,6 +124,7 @@ module ActsAsCustomizable::CalculatedValueCalculatedValueError.create(project: self, custom_field_id:, error_code:, missing_custom_field_ids:)end+ # FIXME: refactor this method to reduce complexitydef create_errors_for_missing_attributes(referenced_values, calculated_fields)errors_created = []