<commit_before>class Label < ActiveRecord::Base
  belongs_to :project
  has_many :label_links, dependent: :destroy
  has_many :issues, through: :label_links, source: :target, source_type: 'Issue'

  validates :color,
            format: { with: /\A\#[0-9A-Fa-f]{6}+\Z/ },
            allow_blank: false
  validates :project, presence: true

  # Don't allow '?', '&', and ',' for label titles
  validates :title, presence: true, format: { with: /\A[^&\?,&]*\z/ }

  scope :order_by_name, -> { reorder("labels.title ASC") }

  def name
    title
  end

  def open_issues_count
    issues.opened.count
  end
end<commit_msg>Labels need to be valid on name<commit_after>class Label < ActiveRecord::Base
  belongs_to :project
  has_many :label_links, dependent: :destroy
  has_many :issues, through: :label_links, source: :target, source_type: 'Issue'

  validates :color,
            format: { with: /\A\#[0-9A-Fa-f]{6}+\Z/ },
            allow_blank: false
  validates :project, presence: true

  # Don't allow '?', '&', and ',' for label titles
  validates :title,
            presence: true,
            format: { with: /\A[^&\?,&]*\z/ },
            uniqueness: true

  scope :order_by_name, -> { reorder("labels.title ASC") }

  def name
    title
  end

  def open_issues_count
    issues.opened.count
  end
end
{'fraction_non_alphanumeric': 0.1448170731707317, 'fraction_numerical': 0.004573170731707317, 'mean_word_length': 2.9667673716012084, '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': '5857739', 'n_tokens_mistral': 459, 'n_tokens_neox': 436, 'n_words': 115}