How to use the jscpd/lib/reporters/json.call function in jscpd

To help you get started, we’ve selected a few jscpd examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github xcatliu / cqc / src / JscpdChecker / jscpdReporter.js View on Github external
function reporterOrigin(options) {
    // Calling the origin reporter
    const jsonReporterResult = jsonReporter.call(this, options);
    const percentage = this.map.getPercentage();
    const limit = options.limit;

    // The log is the third args of the return array, which will output to the stdout
    const log = getPercentageLog({
        percentage,
        limit
    });

    if (percentage > limit) {
        // If the percentage is greater than limit, then we just output the log and exit the process. Keep the logic same with _std-log.coffee
        console.error(log);
        process.exit(1);
    }

    // The first one is the output json
github xcatliu / cqc / src / JscpdChecker / jscpdReporter.js View on Github external
function jscpdReporter(options) {
    // Pass filterFiles option will enhance the result with an extro property: filterDuplicates
    const filterFiles = options.filterFiles;
    // If no filterFiles is passed, then we just return the origin report with our custom logger
    if (typeof filterFiles === 'undefined' || filterFiles.length === 0) {
        return reporterOrigin.call(this, options);
    }

    // Calling the origin reporter and add an extro property filterDuplicates
    const jsonReporterResult = jsonReporter.call(this, options);

    // Get the filterClones
    const filterClones = this.map.clones.filter(({ firstFile, secendFile }) => {
        for (let i = 0; i < filterFiles.length; i++) {
            // If the filepath is same, then return true
            if (filterFiles[i] === firstFile || filterFiles[i] === secendFile) {
                return true;
            }
        }
        return false;
    });

    const filterDuplicates = filterClones.map((clone) => {
        // Keep the structure same with duplicates property
        return {
            lines: clone.linesCount,

jscpd

detector of copy/paste in files

MIT
Latest version published 6 months ago

Package Health Score

85 / 100
Full package analysis

Similar packages