<commit_before>module.exports = {
    lint: function (htmlString) {
        var that = this;

        var rv = {
            status: this.status.OK,
            messages: [],
        };

        var runTest = function (test, messageCallback) {
            var i,l;

            var results = test(htmlString);
            if (results.length > 0) {
                rv.status = that.status.WARNING;
            }

            for (i=0, l=results.length; i<l; i++) {
                rv.messages.push(messageCallback(results[i]));
            }
        };

        var srcOrHrefMessage = function (type) {
            return function (result) {
                return type + ' path in src or href attribute of ' + result.name + ' tag: ' + (result.attribs.src || result.attribs.href);
            };
        };

        runTest(that.findAbsolutePathsInHtml, srcOrHrefMessage('Absolute'));
        runTest(that.findProtocolLessPathsInHtml, srcOrHrefMessage('Protocol-less'));

        return rv;
    }
};<commit_msg>get syntax tree for inline JS<commit_after>var html = require('../cordova-linter/util/html.js'),
    esprima = require('esprima');

module.exports = {
    lint: function (htmlString) {
        var that = this;

        var rv = {
            status: this.status.OK,
            messages: [],
        };

        var runTest = function (test, messageCallback) {
            var results = test(htmlString);
            if (results.length > 0) {
                rv.status = that.status.WARNING;
            }

            for (var i=0, l=results.length; i<l; i++) {
                rv.messages.push(messageCallback(results[i]));
            }
        };

        var srcOrHrefMessage = function (type) {
            return function (result) {
                return type + ' path in src or href attribute of ' + result.name + ' tag: ' + (result.attribs.src || result.attribs.href);
            };
        };

        runTest(that.findAbsolutePathsInHtml, srcOrHrefMessage('Absolute'));
        runTest(that.findProtocolLessPathsInHtml, srcOrHrefMessage('Protocol-less'));

        var js = html.findJs(htmlString);

        for (var i=0, l=js.length; i<l; i++) {
            if (js[i].text) {
                js[i].syntax = esprima.parse(js[i].text);
            } else {
                // TODO: Check that src is local, then use fs to suck it in. Oh, hey, uh, base tags?
            }
        }

        // TODO: Find event assignments in .syntax and flag load event handlers

        return rv;
    }
};
{'fraction_non_alphanumeric': 0.12495025865499403, 'fraction_numerical': 0.0019896538002387586, 'mean_word_length': 1.7178378378378378, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 5, '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': '2613754', 'n_tokens_mistral': 739, 'n_tokens_neox': 706, 'n_words': 170}