<commit_before>'use strict'

const Joi = require('joi')

const parseResponse = response => {
  const parsed = {
    statusCode: response.statusCode
  }

  if (response.body) {
    if (Array.isArray(response.body)) {
      parsed.body = parseArray(response.body)
    } else if (typeof response.body === 'object') {
      parsed.body = parseObject(response.body)
    } else if (response.body.startsWith('Joi')) {
      parsed.body = eval(response.body)
    } else {
      parsed.body = response.body
    }
  }

  if (response.headers) {
    parsed.headers = parseObject(response.headers)
  }

  return parsed
}

module.exports = parseResponse

const parseArray = array => {
  const joiSpec = array.map(item => {
    if (Array.isArray(item)) {
      return parseArray(item)
    } else if (typeof item === 'object') {
      return parseObject(item)
    } else if (item.startsWith('Joi')) {
      return eval(item)
    } else {
      return item
    }
  })

  return Joi.array().items(...joiSpec)
}

const parseObject = object => {
  const keys = Object.keys(object)

  const joiSpec = keys.map(key => {
    if (Array.isArray(object[key])) {
      return parseArray(object[key])
    } else if (typeof object[key] === 'object') {
      return parseObject(object[key])
    } else if (object[key].startsWith('Joi')) {
      return eval(object[key])
    } else {
      return object[key]
    }
  })

  return Joi.object(keys.reduce((acc, key, index) => {
    acc[key] = joiSpec[index]
    return acc
  }, {})).unknown(true)
}
<commit_msg>Removed unnecessary use of spread operator<commit_after>'use strict'

const Joi = require('joi')

const parseResponse = response => {
  const parsed = {
    statusCode: response.statusCode
  }

  if (response.body) {
    if (Array.isArray(response.body)) {
      parsed.body = parseArray(response.body)
    } else if (typeof response.body === 'object') {
      parsed.body = parseObject(response.body)
    } else if (response.body.startsWith('Joi')) {
      parsed.body = eval(response.body)
    } else {
      parsed.body = response.body
    }
  }

  if (response.headers) {
    parsed.headers = parseObject(response.headers)
  }

  return parsed
}

module.exports = parseResponse

const parseArray = array => {
  const joiSpec = array.map(item => {
    if (Array.isArray(item)) {
      return parseArray(item)
    } else if (typeof item === 'object') {
      return parseObject(item)
    } else if (item.startsWith('Joi')) {
      return eval(item)
    } else {
      return item
    }
  })

  return Joi.array().items(joiSpec)
}

const parseObject = object => {
  const keys = Object.keys(object)

  const joiSpec = keys.map(key => {
    if (Array.isArray(object[key])) {
      return parseArray(object[key])
    } else if (typeof object[key] === 'object') {
      return parseObject(object[key])
    } else if (object[key].startsWith('Joi')) {
      return eval(object[key])
    } else {
      return object[key]
    }
  })

  return Joi.object(keys.reduce((acc, key, index) => {
    acc[key] = joiSpec[index]
    return acc
  }, {})).unknown(true)
}

{'fraction_non_alphanumeric': 0.14753566796368353, 'fraction_numerical': 0.0, 'mean_word_length': 2.9001264222503162, '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': '1769358', 'n_tokens_mistral': 1004, 'n_tokens_neox': 1015, 'n_words': 215}