Why?

How?

Analogues

phpcpd

Aho–Corasick

Rabin-Karp

/**
* Hello Copy Pasted World
*/
const name = 'jscpd';

if (name === 'pmd') {
    throw new Error('Use jscpd');
}
[
    {
        "type": "Keyword",
        "value": "const"
    },
    {
        "type": "Identifier",
        "value": "name"
    },
    {
        "type": "Punctuator",
        "value": "="
    },
    {
        "type": "String",
        "value": "'jscpd'"
    },
    {
        "type": "Punctuator",
        "value": ";"
    },
    {
        "type": "Keyword",
        "value": "if"
    },
    {
        "type": "Punctuator",
        "value": "("
    },
    {
        "type": "Identifier",
        "value": "name"
    },
    {
        "type": "Punctuator",
        "value": "==="
    },
    {
        "type": "String",
        "value": "'pmd'"
    },
    {
        "type": "Punctuator",
        "value": ")"
    },
    {
        "type": "Punctuator",
        "value": "{"
    },
    {
        "type": "Keyword",
        "value": "throw"
    },
    {
        "type": "Keyword",
        "value": "new"
    },
    {
        "type": "Identifier",
        "value": "Error"
    },
    {
        "type": "Punctuator",
        "value": "("
    },
    {
        "type": "String",
        "value": "'Use jscpd'"
    },
    {
        "type": "Punctuator",
        "value": ")"
    },
    {
        "type": "Punctuator",
        "value": ";"
    },
    {
        "type": "Punctuator",
        "value": "}"
    }
]
'3237124366',  '07c4845853',  '0b70d4ffe0',  '7bb34abce5',  
'59fb864552',  '9f769a5e93',  'c913cc056b',  '3237124366',  
'4b09c07aa1',  '0b70d4ffe0',  '06b9bc0ef4',  'caf867a125',  
'bd6845a7e7',  '7fb7e4e540',  '5fb26ad7b9',  '66e5a4ee55',  
'06b9bc0ef4',  '3aa73104c6',  '4a43a19740',  'bca573934e',  
'66e5a4ee55',  'da5400f4e2',  '3aa73104c6',  'fecd1071ce',  
'bd6845a7e7',  '7fb7e4e540',  '5fb26ad7b9',  '66e5a4ee55',  
'4ab7ca70d5',  'da5400f4e2',  '7c61a943f3',  '3aa73104c6',  
'c913cc056b',  'a120515c8c' 

JSCPD Architecture

Esprima

Features

  • Detect duplications in programming source code, use semantic of programing languages, can skip comments, empty lines etc.

  • Detect duplications in embedded blocks of code, like <script> or <style> sections in html

  • Blame authors of duplications

  • Generate XML report in pmd-cpd format, JSON report, HTML report

  • Integrate with CI systems, use thresholds for level of duplications

  • The powerful API for extend functionality and usage

Support over 150 programming languages!

Who uses jscpd

  • Code-Inspector is code analysis and technical debt management service.
  • vscode-jscpd - VSCode Copy/Paste detector plugin
  • And lot of other teams and products ...

Plans

More reporters

●Cross projects detections

New API

●Improve performance (add cache, add bloom filters, etc)

Persistent store (NoSQL etc.)

Reports for period

● Cross projects detections

● Improve performance (add cache, add bloom filters, etc)

multi-packages repo

web server

 fix issues :)

 

 

???

Thank you