app/models/laboratory.rb
class Laboratory < ApplicationRecord validates :maximum_capacity, :amount_resources, :name, :initials, presence: true validates :maximum_capacity, :numericality => { :greater_than_or_equal_to => 0 } validates :amount_resources, :numericality => { :greater_than_or_equal_to => 0 } validate :exist_other_with_this_initials validate :exist_other_with_this_name has_many :lessons belongs_to :campus Method `exist_other_with_this_initials` has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Similar blocks of code found in 4 locations. Consider refactoring. def exist_other_with_this_initials @laboratories = Laboratory.all unless initials.nil? @laboratories.each { |l| unless l.id == id errors.add(:initials, 'Outro laboratório já possui sigla informada') if l.initials.casecmp(initials) == 0 end } end end Method `exist_other_with_this_name` has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Similar blocks of code found in 4 locations. Consider refactoring. def exist_other_with_this_name @laboratories = Laboratory.all unless name.nil? @laboratories.each { |l| unless l.id == id errors.add(:initials, 'Outro laboratório já possui nome informada') if l.name.casecmp(name) == 0 end } end endend