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

'use strict';
const options = {
  getCurrentRules: ['current', 'c'],
  getPluginRules: ['plugin', 'p'],
  getAllAvailableRules: ['all-available', 'a'],
  getUnusedRules: ['unused', 'u'],
  n: [],
  error: ['error'],
  nc: [],
  core: ['core'],
  verbose: ['verbose', 'v']
};

const argv = require('yargs')
  .boolean(Object.keys(options))
  .alias(options)
  .default('error', true)
  .default('core', true)
  .argv;

const getRuleURI = require('eslint-rule-documentation');
const getRuleFinder = require('../lib/rule-finder');
const cli = require('../lib/cli-util');

const specifiedFile = argv._[0];
const ruleFinder = getRuleFinder(specifiedFile, argv.core === false);
const errorOut = argv.error && !argv.n;
let processExitCode = argv.u && errorOut ? 1 : 0;

if (!argv.c && !argv.p && !argv.a && !argv.u) {
  console.log('no option provided, please provide a valid option'); // eslint-disable-line no-console
  console.log('usage:'); // eslint-disable-line no-console
  console.log('eslint-find-rules [option] <file> [flag]'); // eslint-disable-line no-console
  process.exit(0);
}

Object.keys(options).forEach(option => {
  let rules;
  const ruleFinderMethod = ruleFinder[option];
  if (argv[option] && ruleFinderMethod) {
    rules = ruleFinderMethod();
    if (argv.verbose) {
      cli.push('\n' + options[option][0] + ' rules\n' + rules.length + ' rules found\n');
    }
    if (rules.length > 0) {
      if (argv.verbose) {
        rules = rules
          .map(rule => [rule, getRuleURI(rule).url])
          .reduce((all, single) => all.concat(single));
        cli.push(rules, 2, false);
      } else {
        cli.push('\n' + options[option][0] + ' rules\n');
        cli.push(rules);
      }
      cli.write();
    } else /* istanbul ignore else */ if (option === 'getUnusedRules') {
      processExitCode = 0;
    }
  }
});

if (processExitCode) {
  process.exit(processExitCode);
}<commit_msg>test(find): work around nyc bug<commit_after>#!/usr/bin/env node

'use strict';
const options = {
  getCurrentRules: ['current', 'c'],
  getPluginRules: ['plugin', 'p'],
  getAllAvailableRules: ['all-available', 'a'],
  getUnusedRules: ['unused', 'u'],
  n: [],
  error: ['error'],
  nc: [],
  core: ['core'],
  verbose: ['verbose', 'v']
};

const argv = require('yargs')
  .boolean(Object.keys(options))
  .alias(options)
  .default('error', true)
  .default('core', true)
  .argv;

const getRuleURI = require('eslint-rule-documentation');
const getRuleFinder = require('../lib/rule-finder');
const cli = require('../lib/cli-util');

const specifiedFile = argv._[0];
const ruleFinder = getRuleFinder(specifiedFile, argv.core === false);
const errorOut = argv.error && !argv.n;
let processExitCode = argv.u && errorOut ? 1 : 0;

if (!argv.c && !argv.p && !argv.a && !argv.u) {
  console.log('no option provided, please provide a valid option'); // eslint-disable-line no-console
  console.log('usage:'); // eslint-disable-line no-console
  console.log('eslint-find-rules [option] <file> [flag]'); // eslint-disable-line no-console
  process.exit(0);
}

Object.keys(options).forEach(option => {
  let rules;
  const ruleFinderMethod = ruleFinder[option];
  if (argv[option] && ruleFinderMethod) {
    rules = ruleFinderMethod();
    if (argv.verbose) {
      cli.push('\n' + options[option][0] + ' rules\n' + rules.length + ' rules found\n');
    }
    if (rules.length > 0) {
      if (argv.verbose) {
        rules = rules
          .map(rule => [rule, getRuleURI(rule).url])
          .reduce((all, single) => all.concat(single));
        cli.push(rules, 2, false);
      } else {
        cli.push('\n' + options[option][0] + ' rules\n');
        cli.push(rules);
      }
      cli.write();
    } else /* istanbul ignore next */ if (option === 'getUnusedRules') {
      processExitCode = 0;
    }
  }
});

if (processExitCode) {
  process.exit(processExitCode);
}
{'fraction_non_alphanumeric': 0.19299591002044988, 'fraction_numerical': 0.004601226993865031, 'mean_word_length': 3.381858902575588, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 13, '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': '1725409', 'n_tokens_mistral': 1341, 'n_tokens_neox': 1329, 'n_words': 288}