<commit_before>/* globals blanket, requirejs, require */

var blanketLoader = function(moduleName) {
    blanket.requiringFile(moduleName);

    var module = requirejs.entries[moduleName];

    var dependencies = "[";
    if (module.deps.length > 0) {
        module.deps.forEach(function (dep) {
            dependencies = dependencies + "\"" + dep + "\", ";
        });

        dependencies = dependencies.substr(0, dependencies.length - 2);
    }
    dependencies = dependencies + "]";

    var content =
        "define(\"" + moduleName + "\", \n  " +
        dependencies + ", \n" +
        module.callback.toString() +
        ");//# sourceURL=" + moduleName + ".js";

    blanket.utils.processFile(
        content,
        moduleName,
        function newLoader() {
            require(moduleName);
        },
        function oldLoader() {
            require(moduleName);
        }
    );
};

// Defer the start of the test run until a call to QUnit.start() this
// allows the modules to be loaded/instrumented prior to the test run
if (typeof(QUnit) === 'object') {
    QUnit.config.autostart = false;
}

var moduleLoader = function() {
	for (moduleName in requirejs.entries) {
		if (moduleName.indexOf(blanket.options('modulePrefix')) === -1) {
		  continue;
		}

		// Loader exclusions are no longer necessary to fix conflicts with addon modules
		// but may still be used to remove data coverage for specific files (e.g. config/environment).
		var exclude = false;
		if (blanket.options('loaderExclusions')) {
			blanket.options('loaderExclusions').forEach(function (loaderExclusion) {
				if (moduleName.indexOf(loaderExclusion) > -1) {
					exclude = true;
				}
			});
		}

		if (!exclude) {
			blanketLoader(moduleName);
		}
	}
}

// This could be a documented capability and move it out of blanket-loader
// it works, can't put it in test-helper b/c it loads too late
blanket.options('enableCoverage',window.location.search.indexOf('coverage') > -1);

// without the above just adding/changing option value in blanket-options.js works
// this is, of course, hijacking the blanket options namespace - so future conflicts could arise
// hack: true
if (blanket.options('enableCoverage')) {
    moduleLoader();
}<commit_msg>#18 modify require to blanket files to ensure deep coverage<commit_after>/* globals blanket, requirejs, require:true */

// This could be a documented capability and move it out of blanket-loader
// it works, can't put it in test-helper b/c it loads too late
blanket.options('enableCoverage',window.location.search.indexOf('coverage') > -1);

var blanketLoader = function(moduleName) {
    blanket.requiringFile(moduleName);

    var module = requirejs.entries[moduleName];

    var dependencies = "[";
    if (module.deps.length > 0) {
        module.deps.forEach(function (dep) {
            dependencies = dependencies + "\"" + dep + "\", ";
        });

        dependencies = dependencies.substr(0, dependencies.length - 2);
    }
    dependencies = dependencies + "]";

    var content =
        "define(\"" + moduleName + "\", \n  " +
        dependencies + ", \n" +
        module.callback.toString() +
        ");//# sourceURL=" + moduleName + ".js";

    blanket.utils.processFile(
        content,
        moduleName,
        function newLoader() {
            require(moduleName);
        },
        function oldLoader() {
            require(moduleName);
        }
    );
};

// Defer the start of the test run until a call to QUnit.start() this
// allows the modules to be loaded/instrumented prior to the test run
if (typeof(QUnit) === 'object') {
    QUnit.config.autostart = false;
}

var shouldExclude = function(moduleName) {
    if (moduleName.indexOf(blanket.options('modulePrefix')) === -1) {
      return false;
    }

    // Loader exclusions are no longer necessary to fix conflicts with addon modules
    // but may still be used to remove data coverage for specific files (e.g. config/environment).
    var exclude = false;
    if (blanket.options('loaderExclusions')) {
        blanket.options('loaderExclusions').forEach(function (loaderExclusion) {
            if (moduleName.indexOf(loaderExclusion) > -1) {
                exclude = true;
            }
        });
    }
    return exclude;
};

var savedRequire = requirejs;
var seen = {};

// proxy require to give us a chance to blanket required files
if (blanket.options('enableCoverage')) {
    require  = function(name) {
        if (typeof(seen[name]) === 'undefined') {
            seen[name]=true;
            if (!shouldExclude(name)) {
                blanketLoader(name);
            }
        }
        return savedRequire(name);
    };
}

{'fraction_non_alphanumeric': 0.12732719880162635, 'fraction_numerical': 0.002995934089450032, 'mean_word_length': 2.643024162120031, 'pattern_counts': {'":': 0, '<': 3, '<?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': '2810022', 'n_tokens_mistral': 1352, 'n_tokens_neox': 1297, 'n_words': 373}