<commit_before>const utils = require('../utils');

/**
 * Attempt to load package.json within the current directory.
 * @param {array} results The output generated by running ESLint.
 * @param {object} config The settings to be used by the formatter.
 * @returns {array} The final list of messages to be displayed in TeamCity
 */
module.exports = (results, config) => {
  const { reportName } = config;
  const outputList = [];
  let errorCount = 0;
  let warningCount = 0;

  outputList.push(`##teamcity[testSuiteStarted name='${reportName}']`);

  results.forEach(result => {
    const { messages } = result;

    if (messages.length === 0) {
      return;
    }

    const filePath = utils.escapeTeamCityString(result.filePath);

    outputList.push(`##teamcity[testStarted name='${reportName}: ${filePath}']`);

    const errorsList = [];
    const warningsList = [];

    messages.forEach(messageObj => {
      const { line, column, message, ruleId, fatal, severity } = messageObj;
      const isError = fatal || severity === 2;

      const escapedRule = utils.escapeTeamCityString(ruleId);
      const escapedMessage = utils.escapeTeamCityString(message);
      const formattedMessage = `line ${line}, col ${column}, ${escapedMessage} (${escapedRule})`;

      if (!isError) {
        warningsList.push(formattedMessage);
        warningCount += 1;
      } else {
        errorsList.push(formattedMessage);
        errorCount += 1;
      }
    });

    // Group errors and warnings together per file
    if (errorsList.length) {
      const errors = errorsList.join('\n');
      outputList.push(
        `##teamcity[testFailed name='${reportName}: ${filePath}' message='${errors}']`
      );
    }

    if (warningsList.length) {
      const warnings = warningsList.join('\n');
      outputList.push(
        `##teamcity[testStdOut name='${reportName}: ${filePath}' out='warning: ${warnings}']`
      );
    }

    outputList.push(`##teamcity[testFinished name='${reportName}: ${filePath}']`);
  });

  outputList.push(`##teamcity[testSuiteFinished name='${reportName}']`);

  outputList.push(
    `##teamcity[buildStatisticValue key='${config.errorStatisticsName}' value='${errorCount}']`
  );
  outputList.push(
    `##teamcity[buildStatisticValue key='${config.warningStatisticsName}' value='${warningCount}']`
  );

  return outputList;
};
<commit_msg>Fix broken tests<commit_after>const utils = require('../utils');

/**
 * Attempt to load package.json within the current directory.
 * @param {array} results The output generated by running ESLint.
 * @param {object} config The settings to be used by the formatter.
 * @returns {array} The final list of messages to be displayed in TeamCity
 */
module.exports = (results, config) => {
  const { reportName } = config;
  const outputList = [];
  let errorCount = 0;
  let warningCount = 0;

  outputList.push(`##teamcity[testSuiteStarted name='${reportName}']`);

  results.forEach(result => {
    const { messages } = result;

    if (messages.length === 0) {
      return;
    }

    const filePath = utils.escapeTeamCityString(result.filePath);

    outputList.push(`##teamcity[testStarted name='${reportName}: ${filePath}']`);

    const errorsList = [];
    const warningsList = [];

    messages.forEach(messageObj => {
      const { line, column, message, ruleId, fatal, severity } = messageObj;

      const formattedMessage = `line ${line}, col ${column}, ${message} (${ruleId})`;

      const isError = fatal || severity === 2;
      if (!isError) {
        warningsList.push(formattedMessage);
        warningCount += 1;
      } else {
        errorsList.push(formattedMessage);
        errorCount += 1;
      }
    });

    // Group errors and warnings together per file
    if (errorsList.length) {
      const errors = utils.escapeTeamCityString(errorsList.join('\n'));
      outputList.push(
        `##teamcity[testFailed name='${reportName}: ${filePath}' message='${errors}']`
      );
    }

    if (warningsList.length) {
      const warnings = utils.escapeTeamCityString(warningsList.join('\n'));
      outputList.push(
        `##teamcity[testStdOut name='${reportName}: ${filePath}' out='warning: ${warnings}']`
      );
    }

    outputList.push(`##teamcity[testFinished name='${reportName}: ${filePath}']`);
  });

  outputList.push(`##teamcity[testSuiteFinished name='${reportName}']`);

  outputList.push(
    `##teamcity[buildStatisticValue key='${config.errorStatisticsName}' value='${errorCount}']`
  );
  outputList.push(
    `##teamcity[buildStatisticValue key='${config.warningStatisticsName}' value='${warningCount}']`
  );

  return outputList;
};

{'fraction_non_alphanumeric': 0.1567276641550054, 'fraction_numerical': 0.0025834230355220667, 'mean_word_length': 3.650650650650651, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '6310961', 'n_tokens_mistral': 1396, 'n_tokens_neox': 1365, 'n_words': 310}