<commit_before>//'use strict'
var fs = require('fs');
var coffeeCoverage = require('coffee-coverage');
var CoverageInstrumentor = coffeeCoverage.CoverageInstrumentor;

/**
 * Mimics the `StringStream` class found in `coffee-coverage`. We use it to get init data from all our instrumented
 * files written to us.
 */
var StringStream = (function() {
    function StringStream() {
        this.data = "";
    }

    StringStream.prototype.write = function(data) {
        this.data += data;
    }

    return StringStream;
})();

/**
 * Write a file with all the initialization code for all the files we intend to report on.
 *
 * Will do all of its work as soon as karma requires it. It will walkn `sourcesBasePath`, instrument it, take all the
 * init code and write that code to `dest`. You can then tell karma to include this file to get a zero count for _all_
 * files you wish to know about.
 */
var addInitCoverage = function(config, logger, helper) {
    var log = logger.create('framework.coffee-coverage');
    var basePath, dest, defaultOptions, instrumentor, initJs, singleOptions;

    if ("undefined" !== typeof config.framework) {
        if (!config.framework.initAllSources) return;
        basePath = config.framework.sourcesBasePath;
        dest = config.framework.dest;
    }

    if (!basePath || !dest) {
        log.warn('Need `sourcesBasePath` and `dest` for framework');
        return;
    }

    defaultOptions = {
        coverageVar: '__coverage__',
        instrumentor: 'istanbul'
    }

    options = helper.merge(defaultOptions, config.framework || {});

    instrumentor = new CoverageInstrumentor(options);<commit_msg>Cleanup. use strict. Define vars at top of scope.<commit_after>'use strict';
var fs = require('fs');
var coffeeCoverage = require('coffee-coverage');
var CoverageInstrumentor = coffeeCoverage.CoverageInstrumentor;

/**
 * Mimics the `StringStream` class found in `coffee-coverage`. We use it to get init data from all our instrumented
 * files written to us.
 */
var StringStream = (function() {
    function StringStream() {
        this.data = "";
    }

    StringStream.prototype.write = function(data) {
        this.data += data;
    }

    return StringStream;
})();

/**
 * Write a file with all the initialization code for all the files we intend to report on.
 *
 * Will do all of its work as soon as karma requires it. It will walkn `sourcesBasePath`, instrument it, take all the
 * init code and write that code to `dest`. You can then tell karma to include this file to get a zero count for _all_
 * files you wish to know about.
 */
var addInitCoverage = function(config, logger, helper) {
    var log = logger.create('framework.coffee-coverage');
    var basePath, dest, defaultOptions, instrumentor, initJs, options, singleOptions;

    if ("undefined" !== typeof config.framework) {
        if (!config.framework.initAllSources) return;
        basePath = config.framework.sourcesBasePath;
        dest = config.framework.dest;
    }

    if (!basePath || !dest) {
        log.warn('Need `sourcesBasePath` and `dest` for framework');
        return;
    }

    defaultOptions = {
        coverageVar: '__coverage__',
        instrumentor: 'istanbul'
    }

    options = helper.merge(defaultOptions, config.framework || {});

    instrumentor = new CoverageInstrumentor(options);
{'fraction_non_alphanumeric': 0.10663082437275985, 'fraction_numerical': 0.0, 'mean_word_length': 3.299101412066752, 'pattern_counts': {'":': 0, '<': 3, '<?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': '5403903', 'n_tokens_mistral': 956, 'n_tokens_neox': 933, 'n_words': 328}