<commit_before>package intellijscalastyle
package codeInspection

import com.intellij.codeInspection._
import com.intellij.openapi.project.Project
import com.intellij.openapi.vfs.VirtualFile
import com.intellij.psi.{PsiDocumentManager, PsiElement, PsiFile}
import org.jetbrains.plugins.scala.lang.psi.api.ScalaFile
import org.scalastyle._

import scala.collection.mutable

object ScalastyleCodeInspection {
  private type TimestampedScalastyleConfiguration = (Long, ScalastyleConfiguration)
  private val cache = new mutable.HashMap[VirtualFile, TimestampedScalastyleConfiguration]()

  private object locations {
    val configFileName = "scalastyle-config.xml"
    val possibleLocations = Seq(".idea", "project")

    def typicalLocation(project: Project): Option[VirtualFile] = {
      val root = project.getBaseDir
      if (root == null) return None

      val dirs = possibleLocations.flatMap(name => Option(root.findChild(name)))
      dirs.flatMap(d => Option(d.findChild(configFileName))).headOption
    }
  }

  private def configuration(project: Project): Option[ScalastyleConfiguration] = {

    def latest(scalastyleXml: VirtualFile): Option[ScalastyleConfiguration] = {<commit_msg>Fixed scalastyle_config.xml name. (It requires _, not -) (cherry picked from commit c8b964d)<commit_after>package intellijscalastyle
package codeInspection

import com.intellij.codeInspection._
import com.intellij.openapi.project.Project
import com.intellij.openapi.vfs.VirtualFile
import com.intellij.psi.{PsiDocumentManager, PsiElement, PsiFile}
import org.jetbrains.plugins.scala.lang.psi.api.ScalaFile
import org.scalastyle._

import scala.collection.mutable

object ScalastyleCodeInspection {
  private type TimestampedScalastyleConfiguration = (Long, ScalastyleConfiguration)
  private val cache = new mutable.HashMap[VirtualFile, TimestampedScalastyleConfiguration]()

  private object locations {
    val configFileName = "scalastyle_config.xml"
    val possibleLocations = Seq(".idea", "project")

    def typicalLocation(project: Project): Option[VirtualFile] = {
      val root = project.getBaseDir
      if (root == null) return None

      val dirs = possibleLocations.flatMap(name => Option(root.findChild(name)))
      dirs.flatMap(d => Option(d.findChild(configFileName))).headOption
    }
  }

  private def configuration(project: Project): Option[ScalastyleConfiguration] = {

    def latest(scalastyleXml: VirtualFile): Option[ScalastyleConfiguration] = {
{'fraction_non_alphanumeric': 0.09437019036046983, 'fraction_numerical': 0.0016200891049007696, 'mean_word_length': 5.415584415584416, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 3}, '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': '4560787', 'n_tokens_mistral': 739, 'n_tokens_neox': 724, 'n_words': 150}