<commit_before>package com.sksamuel.scapegoat.io

import com.sksamuel.scapegoat.{ Warning, Feedback }

import scala.collection.mutable.ListBuffer
import scala.xml.Node

/** @author <NAME> (Axblade) */
object ScalastyleReportWriter {

  private val checkstyleVersion = "5.0"
  private val scapegoat = "scapegoat"

  def toXML(feedback: Feedback): Node = {
    <checkstyle version={ checkstyleVersion } generatedBy={ scapegoat }>
      { feedback.warnings.groupBy(_.sourceFile).foreach(fileToXml) }
    </checkstyle>
  }

  private def fileToXml(fileWarningMapEntry: (String, ListBuffer[Warning])) = {
    val (file, warnings) = fileWarningMapEntry
    <file name={ file }>
      { warnings.map(warningToXml) }
    </file>
  }

  private def warningToXml(warning: Warning) = {
    <error line={ warning.line.toString } message={ warning.text } severity={ warning.level.toString } source={ warning.inspection } snippet={ warning.snippet.orNull }></error>
  }

}<commit_msg>map instead of foreach<commit_after>package com.sksamuel.scapegoat.io

import com.sksamuel.scapegoat.{ Warning, Feedback }

import scala.collection.mutable.ListBuffer
import scala.xml.Node

/** @author <NAME> (Axblade) */
object ScalastyleReportWriter {

  private val checkstyleVersion = "5.0"
  private val scapegoat = "scapegoat"

  def toXML(feedback: Feedback): Node = {
    <checkstyle version={ checkstyleVersion } generatedBy={ scapegoat }>
      { feedback.warnings.groupBy(_.sourceFile).map(fileToXml) }
    </checkstyle>
  }

  private def fileToXml(fileWarningMapEntry: (String, ListBuffer[Warning])) = {
    val (file, warnings) = fileWarningMapEntry
    <file name={ file }>
      { warnings.map(warningToXml) }
    </file>
  }

  private def warningToXml(warning: Warning) = {
    <error line={ warning.line.toString } message={ warning.text } severity={ warning.level.toString } source={ warning.inspection } snippet={ warning.snippet.orNull }></error>
  }

}
{'fraction_non_alphanumeric': 0.12956298200514138, 'fraction_numerical': 0.002056555269922879, 'mean_word_length': 4.316939890710382, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, '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': '3021372', 'n_tokens_mistral': 642, 'n_tokens_neox': 616, 'n_words': 131}