<commit_before>package org.typelevel.sbt

import sbt._
import sbt.impl.GroupArtifactID

import net.virtualvoid.sbt.graph.IvyGraphMLDependencies.{Module, ModuleId}

object Dependencies {

  object known {
    val scala = Dependency("org.scala-lang", "scala-library", ReleaseSeries(2, 10))

    private def scalaz(module: String) = Dependency("org.scalaz", s"scalaz-$module", ReleaseSeries(7, 0))
    val scalazCore = scalaz("core")
    val scalazScalacheckBinding = scalaz("scalacheck-binding")

    val scodec = Dependency("org.typelevel", "scodec-core", ReleaseSeries(1, 0))
    val scalacheck = Dependency("org.scalacheck", "scalacheck", ReleaseSeries(1, 10))

    val all = List(scala, scalazCore, scalazScalacheckBinding, scodec, scalacheck)
  }

  def findFromIDs(all: List[Dependency], groupID: String, rawArtifactID: String): Option[Dependency] = {
    val ScalaSuffix = """(.*)_[.0-9]*""".r
    val artifactID = rawArtifactID match {
      case ScalaSuffix(artifactID) => artifactID
      case _ => rawArtifactID
    }
    all.find(d => d.groupID == groupID && d.artifactID == artifactID)
  }

  def check(all: List[Dependency], logger: Logger, modules: Seq[Module]) = {
    val problems = modules.collect {
      case Module(ModuleId(groupID, artifactID, olderV), _, _, Some(newerV), _) =>
        val msg = s"Version mismatch in $groupID#$artifactID: $olderV and $newerV are different"

        findFromIDs(all, groupID, artifactID) match {
          case Some(dep) =>
            (Version.fromString(olderV), Version.fromString(newerV)) match {
              case (Some(o), Some(n)) =>
                if (dep.minCompatible <= o.series && o.compatible(n)) {
                  logger.info(s"Compatible versions in $groupID#$artifactID: $olderV and $newerV")
                  false
                }
                else {
                  logger.error(msg)
                  true
                }
              case _ =>
                logger.error(msg + ", and version numbers cannot be parsed")
                true
            }
          case None =>
            logger.error(msg + ", and no dependency information available")
            true
        }
    }

    val count = problems.filter(identity).length
    if (count > 0)
      sys.error(s"Dependency check failed, found $count version mismatch(es)")
  }

}

case class Dependency(groupID: String, artifactID: String, minCompatible: ReleaseSeries)
<commit_msg>cleanup<commit_after>package org.typelevel.sbt

import sbt._

import net.virtualvoid.sbt.graph.IvyGraphMLDependencies.{Module, ModuleId}

object Dependencies {

  object known {
    val scala = Dependency("org.scala-lang", "scala-library", ReleaseSeries(2, 10), false)

    private def scalaz(module: String) = Dependency("org.scalaz", s"scalaz-$module", ReleaseSeries(7, 0))
    val scalazCore = scalaz("core")
    val scalazScalacheckBinding = scalaz("scalacheck-binding")

    val scodec = Dependency("org.typelevel", "scodec-core", ReleaseSeries(1, 0))
    val scalacheck = Dependency("org.scalacheck", "scalacheck", ReleaseSeries(1, 10))

    val all = List(scala, scalazCore, scalazScalacheckBinding, scodec, scalacheck)
  }

  def findFromIDs(all: List[Dependency], groupID: String, rawArtifactID: String): Option[Dependency] =
    all.filter(_.matches(groupID, rawArtifactID)) match {
      case head :: Nil => Some(head)
      case Nil => None
      case _ => sys.error(s"Internal error: found more than one match for $groupID:$rawArtifactID; check your `knownDependencies` setting")
    }

  def check(all: List[Dependency], logger: Logger, modules: Seq[Module]) = {
    val notices = modules.collect {
      case Module(ModuleId(groupID, artifactID, olderV), _, _, Some(newerV), _) =>
        val msg = s"Version mismatch in $groupID#$artifactID: $olderV and $newerV are different"

        findFromIDs(all, groupID, artifactID) match {
          case Some(dep) =>
            (Version.fromString(olderV), Version.fromString(newerV)) match {
              case (Some(o), Some(n)) =>
                if (dep.minCompatible <= o.series && o.compatible(n))
                  Right(s"Compatible versions in $groupID#$artifactID: $olderV and $newerV")
                else
                  Left(msg)
              case _ =>
                Left("$msg, and version numbers cannot be parsed")
            }
          case None =>
            Left(s"$msg, and no dependency information available")
        }
    }

    notices.foreach(_.fold(logger.error(_), logger.info(_)))

    val count = notices.filter(_.isLeft).length
    if (count > 0)
      sys.error(s"Dependency check failed, found $count version mismatch(es)")
  }

}

case class Dependency(groupID: String, artifactID: String, minCompatible: ReleaseSeries, scalaSuffix: Boolean = true) {

  def matches(thatGroupID: String, thatArtifactID: String): Boolean = {
    val ScalaSuffix = """(.*)_[.0-9]*""".r
    if (groupID != thatGroupID)
      false
    else
      thatArtifactID match {
        case ScalaSuffix(`artifactID`) if scalaSuffix => true
        case `artifactID` if !scalaSuffix => true
        case _ => false
      }
  }

}

{'fraction_non_alphanumeric': 0.12319968859478396, 'fraction_numerical': 0.00506033476060724, 'mean_word_length': 2.8814199395770395, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 24, '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': '1863375', 'n_tokens_mistral': 1630, 'n_tokens_neox': 1532, 'n_words': 375}