<commit_before>const async = require('async');
const parse = require('dredd-transactions/parse');
const compile = require('dredd-transactions/compile');

const configureReporters = require('./configureReporters');
const resolveLocations = require('./resolveLocations');
const readLocation = require('./readLocation');
const resolveModule = require('./resolveModule');
const logger = require('./logger');
const TransactionRunner = require('./TransactionRunner');
const { applyConfiguration } = require('./configuration');
const annotationToLoggerInfo = require('./annotationToLoggerInfo');


function prefixError(error, prefix) {
  error.message = `${prefix}: ${error.message}`;
  return error;
}


function prefixErrors(decoratedCallback, prefix) {
  return (error, ...args) => {
    if (error) { prefixError(error, prefix); }
    decoratedCallback(error, ...args);
  };
}


function readLocations(locations, options, callback) {
  if (typeof options === 'function') { [options, callback] = [{}, options]; }

  async.map(locations, (location, next) => {
    const decoratedNext = prefixErrors(next, `Unable to load API description document from '${location}'`);
    readLocation(location, options, decoratedNext);
  }, (error, contents) => {
    if (error) { callback(error); return; }

    const apiDescriptions = locations
      .map((location, i) => ({ location, content: contents[i] }));
    callback(null, apiDescriptions);
  });
}


function parseContent(apiDescriptions, callback) {
  async.map(apiDescriptions, ({ location, content }, next) => {
    const decoratedNext = prefixErrors(next, `Unable to parse API description document '${location}'`);
    parse(content, decoratedNext);
  }, (error, parseResults) => {
    if (error) { callback(error); return; }

    const parsedAPIdescriptions = apiDescriptions
      .map((apiDescription, i) => Object.assign({}, parseResults[i], apiDescription));
    callback(null, parsedAPIdescriptions);
  });
}


function compileTransactions(apiDescriptions) {
  return apiDescriptions
    .map(({ mediaType, apiElements, location }) => {
      try {<commit_msg>refactor: simplifies "options" and "callback" in "readLocations"<commit_after>const async = require('async');
const parse = require('dredd-transactions/parse');
const compile = require('dredd-transactions/compile');

const configureReporters = require('./configureReporters');
const resolveLocations = require('./resolveLocations');
const readLocation = require('./readLocation');
const resolveModule = require('./resolveModule');
const logger = require('./logger');
const TransactionRunner = require('./TransactionRunner');
const { applyConfiguration } = require('./configuration');
const annotationToLoggerInfo = require('./annotationToLoggerInfo');


function prefixError(error, prefix) {
  error.message = `${prefix}: ${error.message}`;
  return error;
}


function prefixErrors(decoratedCallback, prefix) {
  return (error, ...args) => {
    if (error) { prefixError(error, prefix); }
    decoratedCallback(error, ...args);
  };
}


function readLocations(locations, options, callback) {
  const usesOptions = typeof options !== 'function';
  const resolvedOptions = usesOptions ? options : {};
  const resolvedCallback = usesOptions ? callback : options;

  async.map(locations, (location, next) => {
    const decoratedNext = prefixErrors(next, `Unable to load API description document from '${location}'`);
    readLocation(location, resolvedOptions, decoratedNext);
  }, (error, contents) => {
    if (error) { resolvedCallback(error); return; }

    const apiDescriptions = locations
      .map((location, i) => ({ location, content: contents[i] }));
    resolvedCallback(null, apiDescriptions);
  });
}


function parseContent(apiDescriptions, callback) {
  async.map(apiDescriptions, ({ location, content }, next) => {
    const decoratedNext = prefixErrors(next, `Unable to parse API description document '${location}'`);
    parse(content, decoratedNext);
  }, (error, parseResults) => {
    if (error) { callback(error); return; }

    const parsedAPIdescriptions = apiDescriptions
      .map((apiDescription, i) => Object.assign({}, parseResults[i], apiDescription));
    callback(null, parsedAPIdescriptions);
  });
}


function compileTransactions(apiDescriptions) {
  return apiDescriptions
    .map(({ mediaType, apiElements, location }) => {
      try {
{'fraction_non_alphanumeric': 0.14852840520191649, 'fraction_numerical': 0.0, 'mean_word_length': 5.157303370786517, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 19, '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': '447377', 'n_tokens_mistral': 1166, 'n_tokens_neox': 1155, 'n_words': 295}