<commit_before>function maybeLog(log, links) {
  links.forEach((link) => {
    if (link.broken) {
      log(link.description)
    }
  })
}

function maybeThrow(links) {
  const brokenLinks = links.filter(({broken}) => !!broken)
  if (brokenLinks.length) {
    let message = `You have ${brokenLinks.length} broken links:`
    brokenLinks.forEach(({description}) => {
      message += `\n${description}`
    })
    throw new Error(message)
  }
}

module.exports = (options, log = console.log) => {
  return (links) => {
    if (options.warn) {
      maybeLog(log, links)
    } else {
      maybeThrow(links)
    }
  }
}<commit_msg>Add file name and some (subjective) readability in the log<commit_after>function maybeLog(log, links) {
  links.forEach((link) => {
    if (link.broken) {
      log(link.description)
    }
  })
}

function maybeThrow(links) {
  const brokenLinks = links.filter(({broken}) => !!broken)

  if (brokenLinks.length) {
    let message = `You have ${brokenLinks.length} broken links:\n`
    brokenLinks.forEach(({filename, description}) => {
      message += `\n${filename} >>> ${description}`
    })
    throw new Error(message)
  }
}

module.exports = (options, log = console.log) => {
  return (links) => {
    if (options.warn) {
      maybeLog(log, links)
    } else {
      maybeThrow(links)
    }
  }
}
{'fraction_non_alphanumeric': 0.16366366366366367, 'fraction_numerical': 0.0, 'mean_word_length': 3.076452599388379, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 16, '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': '3906279', 'n_tokens_mistral': 445, 'n_tokens_neox': 434, 'n_words': 91}