Skip to content

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

[#66093] Use case-in instead of `when Array`

Tobias Dillmanna60fa00f5093
diff --git a/app/models/calculated_values/error_handler.rb b/app/models/calculated_values/error_handler.rb
index 1b84c5fe59e..6a0a82321f6 100644
--- a/app/models/calculated_values/error_handler.rb
+++ b/app/models/calculated_values/error_handler.rb
@@ -86,17 +86,14 @@ module CalculatedValues
custom_field_id = to_id(cf_id)
case error
- when :zero_division
+ in :zero_division
ErrorContext.new(custom_field_id:, error_code: "ERROR_MATHEMATICAL")
- when :missing_value
+ in :missing_value
build_missing_value_error_context(custom_field_id)
- when Array
- if error.first == :unbound_variable
- disabled_fields = error.last.map { to_id(it) }
- ErrorContext.new(custom_field_id:, error_code: "ERROR_DISABLED_VALUE", missing_custom_field_ids: disabled_fields)
- else
- ErrorContext.new(custom_field_id:, error_code: "ERROR_UNKNOWN")
- end
+ in [:unbound_variable, disabled_fields]
+ ErrorContext.new(custom_field_id:,
+ error_code: "ERROR_DISABLED_VALUE",
+ missing_custom_field_ids: disabled_fields.map { to_id(it) })
else
ErrorContext.new(custom_field_id:, error_code: "ERROR_UNKNOWN")
end