lib/reporting/json/JSONReporter.js
function getResultsPerDir(results) {

    /**
     * Decorate the results object with the stats for each directory.
     *
     * @param {object} results - (part of) mutation testing results
     * @returns {object} - Mutation test results decorated with stats
     */
    function addDirStats(results) {
        var dirStats = {
            all: 0,
            killed: 0,
            survived: 0,
            ignored: 0,
            untested: 0
        };

        _.forOwn(results, function(result) {
            var stats = result.stats || addDirStats(result).stats;
            dirStats.all += stats.all;
            dirStats.killed += stats.killed;
            dirStats.survived += stats.survived;
            dirStats.ignored += stats.ignored;
            dirStats.untested += stats.untested;
        });

        results.stats = dirStats;
        return results;
    }

    /**
     * Decorate the results object with the mutation score for each directory.
     *
     * @param {object} results - (part of) mutation testing results, decorated with mutation stats
     * @returns {object} - Mutation test results decorated with mutation scores
     */
    function addMutationScores(results) {
        _.forOwn(results, function(result) {
            if(_.has(result, 'stats')) {
                addMutationScores(result);
            }
        });

        results.mutationScore = getMutationScore(results.stats);
        return results;
    }

    var resultsPerDir = {};

    _.forEach(_.clone(results), function(fileResult) {
        _.set(resultsPerDir, IOUtils.getDirectoryList(fileResult.fileName), fileResult);
    });

    return addMutationScores(addDirStats(resultsPerDir));
}
function getResultsPerDir(results) {

    /**
     * Decorate the results object with the stats for each directory.
     *
     * @param {object} results - (part of) mutation testing results
     * @returns {object} - Mutation test results decorated with stats
     */
    function addDirStats(results) {
        var dirStats = {
            all: 0,
            killed: 0,
            survived: 0,
            ignored: 0,
            untested: 0
        };

        _.forOwn(results, function(result) {
            var stats = result.stats || addDirStats(result).stats;
            dirStats.all += stats.all;
            dirStats.killed += stats.killed;
            dirStats.survived += stats.survived;
            dirStats.ignored += stats.ignored;
            dirStats.untested += stats.untested;
        });

        results.stats = dirStats;
        return results;
    }

    /**
     * Decorate the results object with the mutation score for each directory.
     *
     * @param {object} results - (part of) mutation testing results, decorated with mutation stats
     * @returns {object} - Mutation test results decorated with mutation scores
     */
    function addMutationScores(results) {
        _.forOwn(results, function(result) {
            if(_.has(result, 'stats')) {
                addMutationScores(result);
            }
        });

        results.mutationScore = getMutationScore(results.stats);
        return results;
    }

    var resultsPerDir = {};

    _.forEach(_.clone(results), function(fileResult) {
        _.set(resultsPerDir, IOUtils.getDirectoryList(fileResult.fileName), fileResult);
    });

    return addMutationScores(addDirStats(resultsPerDir));
}
function getResultsPerDir ( results ) { /**
     * Decorate the results object with the stats for each directory.
     *
     * @param {object} results - (part of) mutation testing results
     * @returns {object} - Mutation test results decorated with stats
     */ function addDirStats ( results ) { var dirStats = { all : 0 , killed : 0 , survived : 0 , ignored : 0 , untested : 0 } ; _ . forOwn ( results , function ( result ) { var stats = result . stats || addDirStats ( result ) . stats ; dirStats . all += stats . all ; dirStats . killed += stats . killed ; dirStats . survived += stats . survived ; dirStats . ignored += stats . ignored ; dirStats . untested += stats . untested ; } ) ; results . stats = dirStats ; return results ; } /**
     * Decorate the results object with the mutation score for each directory.
     *
     * @param {object} results - (part of) mutation testing results, decorated with mutation stats
     * @returns {object} - Mutation test results decorated with mutation scores
     */ function addMutationScores ( results ) { _ . forOwn ( results , function ( result ) { if ( _ . has ( result , 'stats' ) ) { addMutationScores ( result ) ; } } ) ; results . mutationScore = getMutationScore ( results . stats ) ; return results ; } var resultsPerDir = { } ; _ . forEach ( _ . clone ( results ) , function ( fileResult ) { _ . set ( resultsPerDir , IOUtils . getDirectoryList ( fileResult . fileName ) , fileResult ) ; } ) ; return addMutationScores ( addDirStats ( resultsPerDir ) ) ; }
Calculate the mutation test results per directory.

@param {object} results - Mutation testing results
@returns {object} - The mutation test results per directory
Calculate the mutation test results per directory .