<commit_before>package com.twitter.scrooge.parser

class FieldValidationException(msg: String) extends java.lang.Exception(msg)
class EnumValidationException(msg: String) extends java.lang.Exception(msg)

object EnumValueTransformer extends Transformer {
  override def transformEnumValues(vs: List[EnumValue]): List[EnumValue] = {
    if (vs.exists(_.value < 0))
      throw new EnumValidationException("Negative user-provided enum value")

    var nextValue = 1
    for (v <- vs) {
      if (v.value == 0)
        v.value = nextValue
      nextValue = v.value + 1
    }

    vs.foldLeft(0) {
      case (max, e) =>
        if (e.value <= max)
          throw new EnumValidationException("Descending enum values")
        else
          e.value
    }

    vs
  }
}

object FieldIdTransformer extends Transformer {
  override def transformFields(fs: List[Field]): List[Field] = {
    if (fs.exists(_.id < 0))<commit_msg>enums don't have to be in order.<commit_after>package com.twitter.scrooge.parser

import scala.collection.mutable

class FieldValidationException(message: String) extends Exception(message)
class EnumValidationException(message: String) extends Exception(message)

object EnumValueTransformer extends Transformer {
  override def transformEnumValues(vs: List[EnumValue]): List[EnumValue] = {
    if (vs.exists(_.value < 0)) {
      throw new EnumValidationException("Negative user-provided enum value")
    }

    val seen = new mutable.HashSet[Int]
    var nextValue = 1
    for (v <- vs) {
      if (v.value == 0) {
        v.value = nextValue
      }
      nextValue = v.value + 1
      if (seen contains v.value) {
        throw new EnumValidationException("Repeating enum values")
      }
      seen += v.value
    }
    vs
  }
}

object FieldIdTransformer extends Transformer {
  override def transformFields(fs: List[Field]): List[Field] = {
    if (fs.exists(_.id < 0))
{'fraction_non_alphanumeric': 0.10542962572482868, 'fraction_numerical': 0.005798629414865577, 'mean_word_length': 3.236607142857143, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 4, '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': '135645', 'n_tokens_mistral': 577, 'n_tokens_neox': 552, 'n_words': 150}