<commit_before>const testFile = require('./testFile')
const Issue = require('../issues/issue')

/**
 * validateMisc
 *
 * takes a list of files and returns an issue for each file
 */
module.exports = function validateMisc(miscFiles) {
  const issuePromises = miscFiles.reduce(
    (issues, file) => [...issues, testFile(file)],
    [],
  )
  return Promise.all(issuePromises).then(res =>
    res
      // extract issue
      .map(obj => obj.issue)
      // remove non-issues
      .filter(o => o instanceof Issue),
  )
}
module.exports = function validateMisc(miscFiles) {
  const issuePromises = miscFiles.reduce(
    (issues, file) => [
      ...issues,
      new Promise(resolve => testFile(file, false, null, resolve)),
    ],
    [],
  )
  return (
    Promise.all(issuePromises)
      // remove non-issues
      .then(res => res.filter(o => o instanceof Issue))
  )
}<commit_msg>switch validation of misc files to testing via readFile<commit_after>const readFile = require('./readFile')
const Issue = require('../issues/issue')

/**
 * validateMisc
 *
 * takes a list of files and returns an issue for each file
 */
module.exports = function validateMisc(miscFiles) {
  const issuePromises = miscFiles.reduce(
    (issues, file) => [
      ...issues,
      readFile(file, false, null).catch(err => {
        if (err instanceof Issue) return err
        throw err
      }),
    ],
    [],
  )
  return (
    Promise.all(issuePromises)
      // remove non-issues
      .then(res => res.filter(o => o instanceof Issue))
  )
}
{'fraction_non_alphanumeric': 0.14136125654450263, 'fraction_numerical': 0.0, 'mean_word_length': 2.7660098522167487, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, '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': '7362822', 'n_tokens_mistral': 466, 'n_tokens_neox': 460, 'n_words': 122}