CRAP Complexity Coverage Location
2.00 1 0/25 (0.00%) crap/html-report/html-report.service.ts (L77 - L124)
    private async initHandlebars(): Promise<void> {
        Handlebars.registerHelper("equals", (a: unknown, b: unknown): boolean => a === b);
        Handlebars.registerHelper("decimal", (x: number): string => x.toFixed(2));
        Handlebars.registerHelper("percentage", (x: number): string => `${(x * 100).toFixed(2)}%`);
        Handlebars.registerHelper("highlightName", (s: string): string => {
            const match = s.match(/^(?<prefix>.*)'(?<name>.*)'(?<suffix>.*)$/);
            if (!match) {
                return s;
            }

            return `${match.groups?.prefix}'<b>${match.groups?.name}</b>${match.groups?.suffix}'`;
        });
        Handlebars.registerHelper(
            "functionReportPath",
            (filePath: string, fileIndex: number): string => `./${filePath}/${fileIndex}.html`,
        );
        Handlebars.registerHelper("functionLineNumber", (report: FunctionReport): string => {
            if (report.end.line != undefined && report.start.line !== report.end.line) {
                return `L${report.start.line} - L${report.end.line}`;
            }
            return `L${report.start.line}`;
        });
        Handlebars.registerHelper("uncoveredLineList", (report: FunctionReport): string =>
            report.uncoveredLines.join(","),
        );
        Handlebars.registerHelper("header", (content: string): string => `${content}_header`);

        Handlebars.registerPartial(
            "overview",
            await this.fileSystemService.loadHandlebarsTemplate(new URL("./template/overview.hbs", import.meta.url)),
        );
        Handlebars.registerPartial(
            "overview_header",
            await this.fileSystemService.loadHandlebarsTemplate(
                new URL("./template/overview_header.hbs", import.meta.url),
            ),
        );
        Handlebars.registerPartial(
            "function",
            await this.fileSystemService.loadHandlebarsTemplate(new URL("./template/function.hbs", import.meta.url)),
        );
        Handlebars.registerPartial(
            "function_header",
            await this.fileSystemService.loadHandlebarsTemplate(
                new URL("./template/function_header.hbs", import.meta.url),
            ),
        );
    }