<commit_before>#!/usr/bin/env node

var depscan = require('depscan')
var valiquire = require('valiquire')
var path = require('path')

// check for unused or missing dependencies in package.json
console.log('Checking for unused or missing dependencies in package.json...')
var scan = depscan('.', path.resolve('.')).report()
if (scan.missing.length) {
  console.error('Dependencies missing in package.json: ' + scan.missing.join(', '))
  process.exit(1)
}
if (scan.unused.length) {
  console.warn('Unused dependencies in package.json: ' + scan.unused.join(', '))
}

// validate require statements (capitalization, relative paths, etc)
console.log('Validating all require statements...')
valiquire('.', false, function (err, validationErrors) {
  console.log('')
  if (err) {
    console.error(err)
    process.exit(1)
  }
  if (validationErrors.length) {
    console.error(validationErrors.length + ' Errors:\n' + validationErrors.join('\n\n'))
    process.exit(1)
  }

  console.log('OK')
})


var pkg = require(path.join(process.cwd(),'package.json'));
var duplicates = [];
if(pkg.dependencies && pkg.devDependencies) {
  console.log('Validating package duplicates...')

  var devDependencies = Object.keys(pkg.devDependencies);
  Object.keys(pkg.dependencies).forEach(function(key){
    if(devDependencies.indexOf(key) > -1) {
      duplicates.push(key);
    }
  });
  if(duplicates.length > 0){
    console.error(duplicates.length + ' duplicates in devDependencies/dependencies:\n' + duplicates.toString() + '\n\n')
    process.exit(1)
  }

  console.log('OK')
}<commit_msg>use stdout, clarify messages, and make all warnings errors<commit_after>#!/usr/bin/env node

var depscan = require('depscan')
var valiquire = require('valiquire')
var path = require('path')

// check for unused or missing dependencies in package.json
console.log('Checking for unused or missing dependencies in package.json...')
var scan = depscan('.', path.resolve('.')).report()
if (scan.missing.length) {
  console.log('Dependencies missing in package.json: ' + scan.missing.join(', '))
  console.log('These should be added.')
  process.exit(1)
}
if (scan.unused.length) {
  console.log('Unused dependencies in package.json: ' + scan.unused.join(', '))
  console.log('These should be removed.')
  process.exit(1)
}

var pkg = require(path.join(process.cwd(),'package.json'));
var duplicates = [];
if(pkg.dependencies && pkg.devDependencies) {
  console.log('Validating duplicate packages...')

  var devDependencies = Object.keys(pkg.devDependencies);
  Object.keys(pkg.dependencies).forEach(function(key){
    if(devDependencies.indexOf(key) > -1) {
      duplicates.push(key);
    }
  });
  if(duplicates.length > 0){
    console.log(duplicates.length + ' found in both dependencies and devDependencies:\n' + duplicates.toString() + '\n\n')
    console.log('These should only be declared once in package.json.')
    process.exit(1)
  }

  console.log('OK')
}

// validate require statements (capitalization, relative paths, etc)
console.log('Validating all require statements...')
valiquire('.', false, function (err, validationErrors) {
  console.log('')
  if (err) {
    console.error(err)
    process.exit(1)
  }
  if (validationErrors.length) {
    console.error(validationErrors.length + ' Errors:\n' + validationErrors.join('\n\n'))
    process.exit(1)
  }

  console.log('OK')
})


{'fraction_non_alphanumeric': 0.16409495548961425, 'fraction_numerical': 0.003857566765578635, 'mean_word_length': 4.308661417322835, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '689546', 'n_tokens_mistral': 1094, 'n_tokens_neox': 1050, 'n_words': 230}