<commit_before>const _ = require('lodash');

const levelWeights = {
    error: 10,
    warning: 3,
    recommendation: 1
};

const calcScore = function calcScore(results, stats) {
    var maxScore, actualScore, balancedScore;

    maxScore = _.reduce(levelWeights, function (max, weight, level) {
        return max + (weight * stats[level]);
    }, 0);

    actualScore = _.reduce(levelWeights, function (max, weight, level) {
        return max - (weight * _.size(results[level]));
    }, maxScore);

    balancedScore = _.ceil((100 / maxScore) * actualScore);

    return {
        value: balancedScore,
        level: _.size(results.error) > 0 ? 'error' : balancedScore < 60 ? 'warning' : 'passing'
    };
};

module.exports = calcScore;
<commit_msg>Added basic JSDocs to the score calculator<commit_after>const _ = require('lodash');

const levelWeights = {
    error: 10,
    warning: 3,
    recommendation: 1
};

/**
 *
 * @param {Object} results
 * @param {Object} results.error
 * @param {Object} results.warning
 * @param {Object} results.recommendation
 * @param {Object} stats
 * @param {Object} stats.error
 * @param {Object} stats.warning
 * @param {Object} stats.recommendation
* @returns {Object}
 */
const calcScore = function calcScore(results, stats) {
    var maxScore, actualScore, balancedScore;

    maxScore = _.reduce(levelWeights, function (max, weight, level) {
        return max + (weight * stats[level]);
    }, 0);

    actualScore = _.reduce(levelWeights, function (max, weight, level) {
        return max - (weight * _.size(results[level]));
    }, maxScore);

    balancedScore = _.ceil((100 / maxScore) * actualScore);

    return {
        value: balancedScore,
        level: _.size(results.error) > 0 ? 'error' : balancedScore < 60 ? 'warning' : 'passing'
    };
};

module.exports = calcScore;

{'fraction_non_alphanumeric': 0.1406761177753544, 'fraction_numerical': 0.011995637949836423, 'mean_word_length': 3.33806146572104, 'pattern_counts': {'":': 0, '<': 5, '<?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': '335469', 'n_tokens_mistral': 584, 'n_tokens_neox': 553, 'n_words': 148}