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

refactor: Improve readability with explicit parameter names

Christophe Bliard33a591b49db5
diff --git a/lib/api/decorators/property_schema_representer.rb b/lib/api/decorators/property_schema_representer.rb
index 2cc240a23e9..186b326c77f 100644
--- a/lib/api/decorators/property_schema_representer.rb
+++ b/lib/api/decorators/property_schema_representer.rb
@@ -82,17 +82,17 @@ module API
property :min_length, exec_context: :decorator
property :max_length, exec_context: :decorator
property :regular_expression, exec_context: :decorator
- property :deprecated, exec_context: :decorator, render_nil: false
+ property :deprecated, exec_context: :decorator
property :options, exec_context: :decorator
- property :location, exec_context: :decorator, render_nil: false
+ property :location, exec_context: :decorator
formattable_property :description,
exec_context: :decorator,
render_nil: false,
setter: nil,
getter: ->(*) do
- next unless description.present?
+ next if description.blank?
::API::Decorators::Formattable.new(description)
end
diff --git a/lib/api/decorators/schema_representer.rb b/lib/api/decorators/schema_representer.rb
index 1b1cedc2979..6be444e12a5 100644
--- a/lib/api/decorators/schema_representer.rb
+++ b/lib/api/decorators/schema_representer.rb
@@ -83,12 +83,12 @@ module API
end
schema_property(property,
- getter,
- show_if,
- required,
- has_default,
- name_source,
- as)
+ getter:,
+ show_if:,
+ required:,
+ has_default:,
+ name_source:,
+ as:)
end
def schema_with_allowed_link(property,
@@ -112,12 +112,12 @@ module API
end
schema_property(property,
- getter,
- show_if,
- required,
- has_default,
- name_source,
- as)
+ getter:,
+ show_if:,
+ required:,
+ has_default:,
+ name_source:,
+ as:)
end
def schema_with_allowed_collection(property,
@@ -150,12 +150,12 @@ module API
end
schema_property(property,
- getter,
- show_if,
- required,
- has_default,
- name_source,
- as)
+ getter:,
+ show_if:,
+ required:,
+ has_default:,
+ name_source:,
+ as:)
end
def schema_with_allowed_string_collection(property,
@@ -189,25 +189,25 @@ module API
end
schema_property(property,
- getter,
- show_if,
- required,
- has_default,
- name_source,
- as)
+ getter:,
+ show_if:,
+ required:,
+ has_default:,
+ name_source:,
+ as:)
end
def schema_property(property,
- getter,
- show_if,
- required,
- has_default,
- name_source,
- property_alias)
+ getter:,
+ show_if:,
+ required:,
+ has_default:,
+ name_source:,
+ as:)
raise ArgumentError unless property
property property,
- as: property_alias,
+ as:,
exec_context: :decorator,
getter:,
if: show_if,
diff --git a/lib/api/v3/queries/schemas/query_schema_representer.rb b/lib/api/v3/queries/schemas/query_schema_representer.rb
index 8c47c735ebe..bc301fd6e63 100644
--- a/lib/api/v3/queries/schemas/query_schema_representer.rb
+++ b/lib/api/v3/queries/schemas/query_schema_representer.rb
@@ -187,12 +187,12 @@ module API
}
schema_property :filters,
- filters_schema,
- true,
- false,
- true,
- :filters,
- :filters
+ getter: filters_schema,
+ show_if: true,
+ required: false,
+ has_default: true,
+ name_source: :filters,
+ as: :filters
schema_with_allowed_collection :group_by,
type: '[]QueryGroupBy',