<commit_before>'use strict';

const fs = require('fs'),
    jdlParser = require('../dsl/jdl_parser'),
    buildException = require('../exceptions/exception_factory').buildException,
    exceptions = require('../exceptions/exception_factory').exceptions;

module.exports = {
  read: readContent,
  readFiles: readFiles
};

function readFiles(files) {
  if (!files || files.length === 0) {
    throw new buildException(
        exceptions.IllegalArgument, 'The file/s must be passed.');
  }
  checkAllTheFilesAreJDLFiles(files);
  return readContent(files.length === 1
      ? readFileContent(files[0])
      : aggregateFiles(files));
};

function readContent(content) {
  if (!content || content.length === 0) {
    throw new buildException(
        exceptions.IllegalArgument, 'The content must be passed.');
  }
  return jdlParser.parse(content);
};

function checkAllTheFilesAreJDLFiles(files) {
  for (var i = 0; i < files.length; i++) {
    checkFileIsJDLFile(files[i]);
  }
}

function checkFileIsJDLFile(file) {
  if (file.slice(file.length - 3, file.length) !== '.jh'
      && file.slice(file.length - 4, file.length) !== '.jdl') {
    throw new buildException(
        exceptions.WrongFile,
        `The passed file '${file}' must end with '.jh' or '.jdl' to be valid.`);
  }
}

function aggregateFiles(files) {
  var content = '';
  for (var i = 0; i < files.length; i++) {
    content = content + '\n' + readFileContent(files[i]);
  }
  return content;
}

function readFileContent(file) {
  if (!fs.existsSync(file) || fs.statSync(file).isDirectory()) {
    throw new buildException(
        exceptions.WrongFile,
        `The passed file '${file}' must exist and must not be a directory.`);
  }
  return fs.readFileSync(file, 'utf-8').toString();<commit_msg>Removed semicolons<commit_after>'use strict';

const fs = require('fs'),
    jdlParser = require('../dsl/jdl_parser'),
    buildException = require('../exceptions/exception_factory').buildException,
    exceptions = require('../exceptions/exception_factory').exceptions;

module.exports = {
  read: readContent,
  readFiles: readFiles
};

function readFiles(files) {
  if (!files || files.length === 0) {
    throw new buildException(
        exceptions.IllegalArgument, 'The file/s must be passed.');
  }
  checkAllTheFilesAreJDLFiles(files);
  return readContent(files.length === 1
      ? readFileContent(files[0])
      : aggregateFiles(files));
}

function readContent(content) {
  if (!content || content.length === 0) {
    throw new buildException(
        exceptions.IllegalArgument, 'The content must be passed.');
  }
  return jdlParser.parse(content);
}

function checkAllTheFilesAreJDLFiles(files) {
  for (var i = 0; i < files.length; i++) {
    checkFileIsJDLFile(files[i]);
  }
}

function checkFileIsJDLFile(file) {
  if (file.slice(file.length - 3, file.length) !== '.jh'
      && file.slice(file.length - 4, file.length) !== '.jdl') {
    throw new buildException(
        exceptions.WrongFile,
        `The passed file '${file}' must end with '.jh' or '.jdl' to be valid.`);
  }
}

function aggregateFiles(files) {
  var content = '';
  for (var i = 0; i < files.length; i++) {
    content = content + '\n' + readFileContent(files[i]);
  }
  return content;
}

function readFileContent(file) {
  if (!fs.existsSync(file) || fs.statSync(file).isDirectory()) {
    throw new buildException(
        exceptions.WrongFile,
        `The passed file '${file}' must exist and must not be a directory.`);
  }
  return fs.readFileSync(file, 'utf-8').toString();
{'fraction_non_alphanumeric': 0.1530641061846936, 'fraction_numerical': 0.005083309799491669, 'mean_word_length': 3.6119791666666665, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, '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': '4193352', 'n_tokens_mistral': 1131, 'n_tokens_neox': 1130, 'n_words': 266}