tasks/code_quality_report.js
function parseJshintResults(fileName, showDetails) {
            var result = {};
            if (grunt.file.exists(fileName)) {
                var content = grunt.file.read(fileName);
                xml2js.parseString(content, {}, function (err, res) {
                    var consoleStatements = content.match(/(console.*)/g);
                    result = {
                        tests: Number(res.testsuite.$.tests),
                        failures: Number(res.testsuite.$.failures),
                        errors: Number(res.testsuite.$.errors),
                        consoleStatements: consoleStatements != null ? consoleStatements.length : 0
                    };

                    if (showDetails) {
                        var details = {};
                        res.testsuite.testcase.forEach(function (key) {
                            if(typeof key.failure !== 'undefined') {
                                var filename = key.$.name.substring(key.$.name.search(/[^\/]+$/g));
                                var failures = key.failure[0]._.replace(/\n/g, "###").split("###");
                                failures.shift();
                                failures.pop();
                                details[filename] = failures;
                            }
                        });
                        result.failureDetails = details;
                    }
                });
            }
            return result;
        }
function parseJshintResults(fileName, showDetails) {
            var result = {};
            if (grunt.file.exists(fileName)) {
                var content = grunt.file.read(fileName);
                xml2js.parseString(content, {}, function (err, res) {
                    var consoleStatements = content.match(/(console.*)/g);
                    result = {
                        tests: Number(res.testsuite.$.tests),
                        failures: Number(res.testsuite.$.failures),
                        errors: Number(res.testsuite.$.errors),
                        consoleStatements: consoleStatements != null ? consoleStatements.length : 0
                    };

                    if (showDetails) {
                        var details = {};
                        res.testsuite.testcase.forEach(function (key) {
                            if(typeof key.failure !== 'undefined') {
                                var filename = key.$.name.substring(key.$.name.search(/[^\/]+$/g));
                                var failures = key.failure[0]._.replace(/\n/g, "###").split("###");
                                failures.shift();
                                failures.pop();
                                details[filename] = failures;
                            }
                        });
                        result.failureDetails = details;
                    }
                });
            }
            return result;
        }
function parseJshintResults ( fileName , showDetails ) { var result = { } ; if ( grunt . file . exists ( fileName ) ) { var content = grunt . file . read ( fileName ) ; xml2js . parseString ( content , { } , function ( err , res ) { var consoleStatements = content . match ( / (console.*) / g ) ; result = { tests : Number ( res . testsuite . $ . tests ) , failures : Number ( res . testsuite . $ . failures ) , errors : Number ( res . testsuite . $ . errors ) , consoleStatements : consoleStatements != null ? consoleStatements . length : 0 } ; if ( showDetails ) { var details = { } ; res . testsuite . testcase . forEach ( function ( key ) { if ( typeof key . failure !== 'undefined' ) { var filename = key . $ . name . substring ( key . $ . name . search ( / [^\/]+$ / g ) ) ; var failures = key . failure [ 0 ] . _ . replace ( / \n / g , "###" ) . split ( "###" ) ; failures . shift ( ) ; failures . pop ( ) ; details [ filename ] = failures ; } } ) ; result . failureDetails = details ; } } ) ; } return result ; }
Parse the jshint results.
@param fileName The filename.
@returns {{junit: {}}}
Parse the jshint results .