<commit_before>class Site < ApplicationRecord
  include DefaultUid
  include Rails.application.routes.url_helpers

  # default values
  default_value_for :email do
    ENV.fetch('SEED_SITE_EMAIL')
  end

  # relations
  has_many :images, dependent: :destroy
  has_many :messages, dependent: :destroy
  has_many :pages, dependent: :destroy
  belongs_to :privacy_policy_page, class_name: 'Page', optional: true

  has_many(
    :main_menu_pages,
    -> { in_list.order(:main_menu_position) },
    class_name: 'Page',
    inverse_of: :site
  )

  # before validations
  TEXT_FIELDS = %i[sidebar_html_content css].freeze
  strip_attributes except: TEXT_FIELDS, collapse_spaces: true, replace_newlines: true
  strip_attributes only: TEXT_FIELDS

  # validations
  validates(
    :host,
    length: { maximum: 64 },
    presence: true,
    uniqueness: true
  )

  validates(
    :name,
    length: { minimum: 3, maximum: 64 },
    presence: true
  )

  validates(
    :google_analytics,
    format: { with: /\AUA-[0-9]+-[0-9]{1,2}\z/, allow_blank: true },
    length: { allow_nil: true, maximum: 32 }
  )

  validates(
    :charity_number,
    length: { allow_nil: true, maximum: 32 }
  )

  validates(
    :links,
    json: { schema: Rails.root.join('config', 'json_schemas', 'site_links.json').to_s }
  )

  def address
    root_url(url_options)
  end

  def url_options
    {
      host: host,
      protocol: ENV['DISABLE_SSL'] ? 'http' : 'https',
      port: ENV['EMAIL_LINK_PORT']
    }
  end
end<commit_msg>Fix rubocop error<commit_after>class Site < ApplicationRecord
  include DefaultUid
  include Rails.application.routes.url_helpers

  # default values
  default_value_for :email do
    ENV.fetch('SEED_SITE_EMAIL')
  end

  # relations
  has_many :images, dependent: :destroy
  has_many :messages, dependent: :destroy
  has_many :pages, dependent: :destroy
  belongs_to :privacy_policy_page, class_name: 'Page', optional: true

  has_many(
    :main_menu_pages,
    -> { in_list.order(:main_menu_position) },
    class_name: 'Page',
    inverse_of: :site
  )

  # before validations
  TEXT_FIELDS = %i[sidebar_html_content css].freeze
  strip_attributes except: TEXT_FIELDS, collapse_spaces: true, replace_newlines: true
  strip_attributes only: TEXT_FIELDS

  # validations
  validates(
    :host,
    length: { maximum: 64 },
    presence: true,
    uniqueness: true
  )

  validates(
    :name,
    length: { minimum: 3, maximum: 64 },
    presence: true
  )

  validates(
    :google_analytics,
    format: { with: /\AUA-[0-9]+-[0-9]{1,2}\z/, allow_nil: true },
    length: { allow_nil: true, maximum: 32 }
  )

  validates(
    :charity_number,
    length: { allow_nil: true, maximum: 32 }
  )

  validates(
    :links,
    json: { schema: Rails.root.join('config', 'json_schemas', 'site_links.json').to_s }
  )

  def address
    root_url(url_options)
  end

  def url_options
    {
      host: host,
      protocol: ENV['DISABLE_SSL'] ? 'http' : 'https',
      port: ENV['EMAIL_LINK_PORT']
    }
  end
end
{'fraction_non_alphanumeric': 0.11795891318754141, 'fraction_numerical': 0.009940357852882704, 'mean_word_length': 3.369030390738061, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2050737', 'n_tokens_mistral': 1107, 'n_tokens_neox': 1064, 'n_words': 233}