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
fix some rubocop offenses for CostEntry
Klaus Zanders5846c5350a9b
diff --git a/modules/costs/app/models/cost_entry.rb b/modules/costs/app/models/cost_entry.rbindex bb1a9bdc904..732f83ebc6d 100644--- a/modules/costs/app/models/cost_entry.rb+++ b/modules/costs/app/models/cost_entry.rb@@ -44,15 +44,14 @@ class CostEntry < ApplicationRecordinclude ActiveModel::ForbiddenAttributesProtection- validates_presence_of :entity, :project_id, :user_id, :logged_by_id, :cost_type_id, :units, :spent_on- validates_numericality_of :units, allow_nil: false, message: :invalid- validates_length_of :comments, maximum: 255, allow_nil: true-- before_save :before_save- before_validation :before_validationafter_initialize :after_initialize+ before_validation :before_validation+ before_save :before_savevalidate :validate+ validates :entity, :project_id, :user_id, :logged_by_id, :cost_type_id, :units, :spent_on, presence: true+ validates :units, numericality: { allow_nil: false, message: :invalid }+ validates :comments, length: { maximum: 255, allow_nil: true }validates :entity_type,inclusion: { in: ALLOWED_ENTITY_TYPES },allow_blank: true@@ -79,7 +78,7 @@ class CostEntry < ApplicationRecordself.project = entity.project if entity && project.nil?end- def validate+ def validate # rubocop:disable Metrics/AbcSize, Metrics/PerceivedComplexityerrors.add :units, :invalid if units&.negative?errors.add :project_id, :invalid if project.nil?errors.add :entity, :invalid if entity.nil? || (project != entity.project)