<commit_before>---
description: runs the linter
dependencies:
    map: tools/map
    rsvp: tools/rsvp
    objLoop: tools/objLoop

    linter: douglas/main

    test: richard/test
    createSpy: richard/createSpy
---
test(__module.AMDid, function (it) {
    function moduleFactory() {
        return {
            linter: createSpy("linter", {}),
            createModule: function () {
                return __module.constructor(map, rsvp, objLoop, this.linter);
            }
        };
    }

    it("runs lint", function (expect) {
        var factory = moduleFactory();
        var linter = factory.createModule();

        linter("foo", {"foo": { expectations: {}, dependencyVariables: [] }}, {}, function () {});

        expect(factory.linter).toHaveBeenCalled();
    });

});
---
---
function reportResult(result, Module, writeLog) {
    if (result.passed) {
        writeLog(1, "No lint found in " + Module);
    } else {
        writeLog(1, "Lint found in " + Module);
        writeLog(2, result.details);
    }
}

function runLint(AMDid, snapshot, lintpreferences, writeLog) {
    var promise = rsvp.promise();
    var module = snapshot[AMDid];
    
    writeLog(0, "Running linter...");
    //module expectations are in scope
    var predefinedVariables = objLoop(module.expectations, function (key, value) {
        return false; //false indicates to jsHint that you may not assign to the variable;
    });
    //dependencies are in scope
    map(module.dependencyVariables, function (variableName) {
        predefinedVariables[variableName] = false;
    });
    
    //when evaluating the test code, __module is in scope as well
    predefinedVariables["__module"] = false;
    
    var testCodeResult = linter(module.testFunctionBody, lintpreferences, predefinedVariables);
    reportResult(testCodeResult, "ModuleTests", writeLog);

    delete predefinedVariables["__module"];

    var moduleCodeResult = linter(module.defineFunctionBody, lintpreferences, predefinedVariables);
    reportResult(moduleCodeResult, "Module", writeLog);

    if (testCodeResult.passed && moduleCodeResult.passed) {
        promise.fulfill();
    } else {
        promise.reject();
    }

    return promise;
}
return runLint;<commit_msg>Don't crash if jslint crashes.<commit_after>---
description: runs the linter
dependencies:
    map: tools/map
    rsvp: tools/rsvp
    objLoop: tools/objLoop

    linter: douglas/main

    test: richard/test
    createSpy: richard/createSpy
---
test(__module.AMDid, function (it) {
    function moduleFactory() {
        return {
            linter: createSpy("linter", {}),
            createModule: function () {
                return __module.constructor(map, rsvp, objLoop, this.linter);
            }
        };
    }

    it("runs lint", function (expect) {
        var factory = moduleFactory();
        var linter = factory.createModule();

        linter("foo", {"foo": { expectations: {}, dependencyVariables: [] }}, {}, function () {});

        expect(factory.linter).toHaveBeenCalled();
    });

});
---
---
function reportResult(result, Module, writeLog) {
    if (result.passed) {
        writeLog(1, "No lint found in " + Module);
    } else {
        writeLog(1, "Lint found in " + Module);
        writeLog(2, result.details);
    }
}

function runLint(AMDid, snapshot, lintpreferences, writeLog) {
    var promise = rsvp.promise();
    try {
        var module = snapshot[AMDid];

        writeLog(0, "Running linter...");
        //module expectations are in scope
        var predefinedVariables = objLoop(module.expectations, function (key, value) {
            return false; //false indicates to jsHint that you may not assign to the variable;
        });
        //dependencies are in scope
        map(module.dependencyVariables, function (variableName) {
            predefinedVariables[variableName] = false;
        });

        //when evaluating the test code, __module is in scope as well
        predefinedVariables["__module"] = false;

        var testCodeResult = linter(module.testFunctionBody, lintpreferences, predefinedVariables);
        reportResult(testCodeResult, "ModuleTests", writeLog);

        delete predefinedVariables["__module"];

        var moduleCodeResult = linter(module.defineFunctionBody, lintpreferences, predefinedVariables);
        reportResult(moduleCodeResult, "Module", writeLog);

        if (testCodeResult.passed && moduleCodeResult.passed) {
            promise.fulfill();
        } else {
            promise.reject();
        }
    } catch(e) {
        promise.reject(e);
    }
    return promise;
}
return runLint;
{'fraction_non_alphanumeric': 0.12029424491562095, 'fraction_numerical': 0.0017308524448290783, 'mean_word_length': 2.707297514033681, 'pattern_counts': {'":': 2, '<': 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': '2823197', 'n_tokens_mistral': 1329, 'n_tokens_neox': 1288, 'n_words': 322}