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

[#64348] Use compact if/elsif instead of early returns

Tobias Dillmann8eaeaea334b5
diff --git a/app/models/custom_field/calculated_value.rb b/app/models/custom_field/calculated_value.rb
index 940a6238dce..ae610d4233a 100644
--- a/app/models/custom_field/calculated_value.rb
+++ b/app/models/custom_field/calculated_value.rb
@@ -46,15 +46,9 @@ module CustomField::CalculatedValue
def validate_formula
if formula_string.blank?
errors.add(:formula, :blank)
- return
- end
-
- unless formula_contains_only_allowed_characters?
+ elsif !formula_contains_only_allowed_characters?
errors.add(:formula, :invalid_characters)
- return
- end
-
- unless valid_formula_syntax?
+ elsif !valid_formula_syntax?
errors.add(:formula, :invalid)
end
end