Fixed codeclimate issues

This commit is contained in:
Sergei Tsoganov 2023-05-15 14:23:41 +03:00
parent 0f16ec77f5
commit dc41cfb103
3 changed files with 11 additions and 10 deletions

View file

@ -13,6 +13,7 @@ class WhiteIp < ApplicationRecord
def validate_ipv4_and_ipv6
return if ipv4.present? || ipv6.present?
errors.add(:base, I18n.t(:ipv4_or_ipv6_must_be_present))
end
@ -32,12 +33,12 @@ class WhiteIp < ApplicationRecord
errors.add(:ipv6, :invalid)
end
API = 'api'
REGISTRAR = 'registrar'
INTERFACES = [API, REGISTRAR]
API = 'api'.freeze
REGISTRAR = 'registrar'.freeze
INTERFACES = [API, REGISTRAR].freeze
scope :api, -> { where("interfaces @> ?::varchar[]", "{#{API}}") }
scope :registrar_area, -> { where("interfaces @> ?::varchar[]", "{#{REGISTRAR}}") }
scope :api, -> { where('interfaces @> ?::varchar[]', "{#{API}}") }
scope :registrar_area, -> { where('interfaces @> ?::varchar[]', "{#{REGISTRAR}}") }
def interfaces=(interfaces)
super(interfaces.reject(&:blank?))
@ -84,7 +85,7 @@ class WhiteIp < ApplicationRecord
ipv6,
interfaces.join(', ').upcase,
created_at,
updated_at
updated_at,
]
end
end