jscpd

jscpd is a tool for detect copy/paste "design pattern" in programming source code.

Version

3.2.1

Runtime

Node.js v12.14.1 npm 6.13.4

Supported Languages

C C++ C# Closure ClojureScript CoffeeScript CSS Go HTML Java JavaScript Kotlin Markdown Objective-C PHP Python Ruby Scala Shell Swift TypeScript

Official Documentation

https://github.com/kucherenko/jscpd

YAML Configuration

jscpd:

  • input:

    Patterns to include in execution and reports.

  • ignore:

    Patterns to exclude from execution and reports.

  • auto-fix:

    N/A

  • config-file:

    Alias of --config option.

  • machine:

    • cpu:

      Amount of CPU. The default machine has 0.25 CPU with 960 MiB RAM.

  • options:

    Below is the list of options that are supported:

    -l, --min-lines [number]   min size of duplication in code lines (Default is 5)
    -k, --min-tokens [number]  min size of duplication in code tokens (Default is 50)
    -x, --max-lines [number]   max size of source in lines (Default is 500)
    -z, --max-size [string]    max size of source in bytes, examples: 1kb, 1mb, 120kb (Default is 30kb)
    -c, --config [string]      path to config file (Default is .cpd.json in <path>)
    -i, --ignore [string]      glob pattern for files what should be excluded from duplication detection
    -m, --mode [string]        mode of quality of search, can be "strict", "mild" and "weak" (Default is "mild")
    -f, --format [string]      format or formats separated by comma (Example php,javascript,python)
    -b, --blame                blame authors of duplications (get information about authors from git)
    -n, --noSymlinks           dont use symlinks for detection in files
    --ignoreCase               ignore case of symbols in code (experimental)
    -g, --gitignore            ignore all files from .gitignore file
    --formats-exts [string]    list of formats with file extensions (javascript:es,es6;dart:dt)
    --skipLocal                skip duplicates in local folders, just detect cross folders duplications
    
  • thresholds:

    • num-issues:

      No tool specific severity levels are available.

  • incremental:

    N/A

    Note: The incremental analysis cannot be supported for jscpd. This is because unchanged files also need to be compared with changed ones.

  • experimental:

    No tool specific experimental options are available.

YAML Examples

  • With default options:

    inspecode:
      tools:
        jscpd: default
    
  • With custom machine:

    inspecode:
      tools:
        jscpd:
          machine:
            cpu: 1.5 # 1.5 CPU, 5760 MiB RAM
    
  • With custom options:

    inspecode:
      tools:
        jscpd:
          options:
            --min-lines: 10
    
  • With a configuration file:

    inspecode:
      tools:
        jscpd:
          config-file: test/.jscpd.json
    

    The above configuration is equivalent to:

    inspecode:
      tools:
        jscpd:
          options:
            --config: test/.jscpd.json
    

Configuration File Detection

If no configuration files are specified via config-file or options field, Inspecode first lets jscpd to find configuration files in your repository.

In addition, if jscpd cannot find any configuration files, Inspecode also walks the file tree in lexical order in your repository to find a configuration file named .jscpd.json and specifies the file first found to jscpd automatically via --config option.

Note: Inspecode ignores specific configuration files while searching. See Configuration > Tool Configuration > Field: config-file for detail.

If the configuration file detected by Inspecode is not the one you want to use or you do not want to use any configuration files, you can disable Inspecode from detecting configuration files by explicitly setting an empty string to config-file field like below:

inspecode:
  tools:
    jscpd:
      config-file: ""

results matching ""

    No results matching ""