<commit_before>"use strict";

const HtmlBuilder    = require("./html-builder");
const metricRow      = require("./metric-row");
const reportStyle    = require("./report-style");
const header         = require("./header");
const functionsTable = require("./functions-table");
const link           = require("./link").localLink;

const overviewMetrics = {
    maintainability:
    {
        title: "Maintainability",
        description: "Value between 0 and 100. Represents the relative ease of maintaining the code. A high value means better maintainability.",
        errorRange: [0, 10],
        warningRange: [10, 20],
        infoUrl: "https://blogs.msdn.microsoft.com/zainnab/2011/05/26/code-metrics-maintainability-index/"
    },
    loc:
    {
        title: "Lines of code",
        description: "Logical number of source lines of code.",
        infoUrl: "https://en.wikipedia.org/wiki/Source_lines_of_code"
    },
    difficulty:
    {
        title: "Difficulty",
        description: "How difficult it is to write or understand the program.",
        errorRange: [60, 9999],
        warningRange: [30, 60],
        infoUrl: "https://en.wikipedia.org/wiki/Halstead_complexity_measures"
    },
    bugs:
    {
        title: "Estimated # of Bugs",
        description: "Estimate for the number of errors in the implementation.",
        errorRange: [60, 9999],
        warningRange: [30, 60],
        infoUrl: "https://en.wikipedia.org/wiki/Halstead_complexity_measures"
    },
};

function backLink() {
    return `${ link("", "&#9664; back") }`;
}

function buildFileSummary(htmlBuilder, analysis) {
    const metrics = [
        { metric: overviewMetrics.maintainability, value: analysis.maintainability },
        { metric: overviewMetrics.loc,             value: analysis.sloc },
        { metric: overviewMetrics.difficulty,      value: analysis.difficulty },
        { metric: overviewMetrics.bugs,            value: analysis.bugs },
    ];

    htmlBuilder
        .appendBody(header("Summary"))
        .appendBody(metricRow(metrics))
        .appendBody(header("Functions"))
        .appendBody(functionsTable(analysis))
        .appendBody("<br><br>")
        .appendBody(backLink());
}

function FileReport(analysis) {
    function toHtml() {
        const htmlBuilder = new HtmlBuilder();

        htmlBuilder.appendStyle(reportStyle);

        buildFileSummary(htmlBuilder, analysis);

        return htmlBuilder.toHtml();
    }

    this.toHtml = toHtml;
}

module.exports = FileReport;<commit_msg>Hide back link on single file analysis<commit_after>"use strict";

const HtmlBuilder    = require("./html-builder");
const metricRow      = require("./metric-row");
const reportStyle    = require("./report-style");
const header         = require("./header");
const functionsTable = require("./functions-table");
const link           = require("./link").localLink;

const overviewMetrics = {
    maintainability:
    {
        title: "Maintainability",
        description: "Value between 0 and 100. Represents the relative ease of maintaining the code. A high value means better maintainability.",
        errorRange: [0, 10],
        warningRange: [10, 20],
        infoUrl: "https://blogs.msdn.microsoft.com/zainnab/2011/05/26/code-metrics-maintainability-index/"
    },
    loc:
    {
        title: "Lines of code",
        description: "Logical number of source lines of code.",
        infoUrl: "https://en.wikipedia.org/wiki/Source_lines_of_code"
    },
    difficulty:
    {
        title: "Difficulty",
        description: "How difficult it is to write or understand the program.",
        errorRange: [60, 9999],
        warningRange: [30, 60],
        infoUrl: "https://en.wikipedia.org/wiki/Halstead_complexity_measures"
    },
    bugs:
    {
        title: "Estimated # of Bugs",
        description: "Estimate for the number of errors in the implementation.",
        errorRange: [60, 9999],
        warningRange: [30, 60],
        infoUrl: "https://en.wikipedia.org/wiki/Halstead_complexity_measures"
    },
};

function backLink() {
    return `${ link("", "&#9664; back") }`;
}

function buildFileSummary(htmlBuilder, analysis, includeBackLink) {
    const metrics = [
        { metric: overviewMetrics.maintainability, value: analysis.maintainability },
        { metric: overviewMetrics.loc,             value: analysis.sloc },
        { metric: overviewMetrics.difficulty,      value: analysis.difficulty },
        { metric: overviewMetrics.bugs,            value: analysis.bugs },
    ];

    htmlBuilder
        .appendBody(header("Summary"))
        .appendBody(metricRow(metrics))
        .appendBody(header("Functions"))
        .appendBody(functionsTable(analysis))
        .appendBody("<br><br>");

    if (includeBackLink) {
        htmlBuilder.appendBody(backLink());
    }
}

function FileReport(analysis, includeBackLink = true) {
    function toHtml() {
        const htmlBuilder = new HtmlBuilder();

        htmlBuilder.appendStyle(reportStyle);

        buildFileSummary(htmlBuilder, analysis, includeBackLink);

        return htmlBuilder.toHtml();
    }

    this.toHtml = toHtml;
}

module.exports = FileReport;
{'fraction_non_alphanumeric': 0.1277294685990338, 'fraction_numerical': 0.016618357487922706, 'mean_word_length': 2.7480086893555393, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 8, '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': '6479945', 'n_tokens_mistral': 1517, 'n_tokens_neox': 1431, 'n_words': 339}