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

linting

ulfertsd0c26fc4d18e
diff --git a/lib/api/v3/projects/project_eager_loading_wrapper.rb b/lib/api/v3/projects/project_eager_loading_wrapper.rb
index be51ed26310..84bca3cacb0 100644
--- a/lib/api/v3/projects/project_eager_loading_wrapper.rb
+++ b/lib/api/v3/projects/project_eager_loading_wrapper.rb
@@ -36,7 +36,7 @@ module API
class << self
def wrap(projects)
- custom_fields = if projects && !projects.empty?
+ custom_fields = if projects.present?
projects.first.available_custom_fields
end
diff --git a/lib/api/v3/work_packages/eager_loading/custom_value.rb b/lib/api/v3/work_packages/eager_loading/custom_value.rb
index 8a239f09b84..f747937d538 100644
--- a/lib/api/v3/work_packages/eager_loading/custom_value.rb
+++ b/lib/api/v3/work_packages/eager_loading/custom_value.rb
@@ -118,8 +118,7 @@ module API
scope
.where(id: ids_of_values)
- .map { |v| [v.id, v] }
- .to_h
+ .index_by(&:id)
end
def custom_values_of(field_format)
@@ -143,8 +142,7 @@ module API
@loaded_custom_fields_by_id ||= begin
WorkPackageCustomField
.where(id: usages.map { |u| u['custom_field_id'] }.uniq)
- .map { |cf| [cf.id, cf] }
- .to_h
+ .index_by(&:id)
end
@loaded_custom_fields_by_id[id]
diff --git a/lib/plugins/acts_as_journalized/lib/journal_formatter/named_association.rb b/lib/plugins/acts_as_journalized/lib/journal_formatter/named_association.rb
index b73b57e75bd..5b605c4bac5 100644
--- a/lib/plugins/acts_as_journalized/lib/journal_formatter/named_association.rb
+++ b/lib/plugins/acts_as_journalized/lib/journal_formatter/named_association.rb
@@ -69,7 +69,7 @@ module JournalFormatter
def associated_object(klass, id, options = {})
cache = options[:cache]
- if cache && cache.is_a?(Acts::Journalized::JournalObjectCache)
+ if cache.is_a?(Acts::Journalized::JournalObjectCache)
cache.fetch(klass, id) do |k, i|
k.find_by(id: i)
end
@@ -85,9 +85,7 @@ module JournalFormatter
def class_from_field(field)
association = @journal.journable.class.reflect_on_association(field)
- if association
- association.class_name.constantize
- end
+ association&.class_name&.constantize
end
end
end