<commit_before>library dherkin;

import "dart:io";
import "dart:async";
import "dart:mirrors";

import 'package:args/args.dart';
import "package:log4dart/log4dart.dart";
import "package:worker/worker.dart";

import 'dherkin_core.dart';
export 'dherkin_core.dart';


Logger _log = LoggerFactory.getLogger("dherkin");
ResultBuffer _buffer = new ConsoleBuffer();


/**
 * Runs specified gherkin files with provided flags.
 * [args] may be a list of filepaths.
 */
Future run(args) {
  var options = _parseArguments(args);

  if (!options["debug"]) {  // unsure about effect of this.
    LoggerFactory.config[".*"].debugEnabled = false;
  }

  int okScenariosCount = 0;
  int koScenariosCount = 0;

  var runTags = [];
  if (options["tags"] != null) {
    runTags = options["tags"].split(",");
  }

  var worker = new Worker(spawnLazily: false, poolSize: Platform.numberOfProcessors);

  var featureFiles = options.rest;

  var futures = [];
  return findStepRunners().then((stepsRunners) {
    return Future.forEach(featureFiles, (filePath) {
      Completer c = new Completer();
      new File(filePath).readAsLines().then((List<String> contents) {
        return worker.handle(new GherkinParserTask(contents)).then((feature) {
          futures.add(feature.execute(worker, _buffer, stepsRunners, runTags));
          c.complete();
        });
      });
      return c.future;
    }).whenComplete(() => Future.wait(futures).whenComplete(() => worker.close()));
  });

}


/**
 * Parses command line arguments.
 */
ArgResults _parseArguments(args) {
  var argParser = new ArgParser();
  argParser.addFlag('junit', defaultsTo: true); // this is not used ?
  argParser.addFlag('debug', defaultsTo: true);
  argParser.addOption("tags");
  return argParser.parse(args);
}
<commit_msg>Cleanup.<commit_after>library dherkin;

import "dart:io";
import "dart:async";
import "dart:mirrors";

import 'package:args/args.dart';
import "package:log4dart/log4dart.dart";
import "package:worker/worker.dart";

import 'dherkin_core.dart';
export 'dherkin_core.dart';


Logger _log = LoggerFactory.getLogger("dherkin");
ResultBuffer _buffer = new ConsoleBuffer();


/**
 * Runs specified gherkin files with provided flags.
 * [args] may be a list of filepaths.
 */
Future run(args) {
  var options = _parseArguments(args);

  if (!options["debug"]) {  // unsure about effect of this.
    LoggerFactory.config[".*"].debugEnabled = false;
  }

  int okScenariosCount = 0;
  int koScenariosCount = 0;

  var runTags = [];
  if (options["tags"] != null) {
    runTags = options["tags"].split(",");
  }

  var worker = new Worker(spawnLazily: false, poolSize: Platform.numberOfProcessors);

  var featureFiles = options.rest;

  var futures = [];
  return findStepRunners().then((stepsRunners) {
    return Future.forEach(featureFiles, (filePath) {
      Completer c = new Completer();
      new File(filePath).readAsLines().then((List<String> contents) {
        return worker.handle(new GherkinParserTask(contents)).then((feature) {
          futures.add(feature.execute(worker, _buffer, stepsRunners, runTags));
          c.complete();
        });
      });
      return c.future;
    }).whenComplete(() => Future.wait(futures).whenComplete(() => worker.close()));
  });

}


/**
 * Parses command line arguments.
 */
ArgResults _parseArguments(args) {
  var argParser = new ArgParser();
  //argParser.addFlag('junit', defaultsTo: true); // this is not used ?
  argParser.addFlag('debug', defaultsTo: true);
  argParser.addOption("tags");
  return argParser.parse(args);
}

{'fraction_non_alphanumeric': 0.15291467192340186, 'fraction_numerical': 0.002252886510842016, 'mean_word_length': 4.074285714285714, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, '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': '2591640', 'n_tokens_mistral': 1153, 'n_tokens_neox': 1132, 'n_words': 252}