• Stars
    star
    3,183
  • Rank 13,495 (Top 0.3 %)
  • Language
    TypeScript
  • License
    MIT License
  • Created almost 11 years ago
  • Updated 9 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Copy/paste detector for programming source code.

jscpd

stand with Ukraine

npm jscpd license npm

jscpd CI codecov FOSSA Status Backers on Open Collective Sponsors on Open Collective

NPM

Copy/paste detector for programming source code, supports 150+ formats.

Copy/paste is a common technical debt on a lot of projects. The jscpd gives the ability to find duplicated blocks implemented on more than 150 programming languages and digital formats of documents. The jscpd tool implements Rabin-Karp algorithm for searching duplications.

Packages of jscpd

name version description
jscpd npm main package for jscpd (cli and API for detections included)
@jscpd/core npm core detection algorithm, can be used for detect duplication in different environments, one dependency to eventemitter3
@jscpd/finder npm detector of duplication in files
@jscpd/tokenizer npm tool for tokenize programming source code
@jscpd/leveldb-store npm LevelDB store, used for big repositories, slower than default store
@jscpd/html-reporter npm Html reporter for jscpd
@jscpd/badge-reporter npm Badge reporter for jscpd

Installation

$ npm install -g jscpd

Usage

$ npx jscpd /path/to/source

or

$ jscpd /path/to/code

or

$ jscpd --pattern "src/**/*.js"

More information about cli here.

Programming API

For integration copy/paste detection to your application you can use programming API:

jscpd Promise API

import {IClone} from '@jscpd/core';
import {jscpd} from 'jscpd';

const clones: Promise<IClone[]> = jscpd(process.argv);

jscpd async/await API

import {IClone} from '@jscpd/core';
import {jscpd} from 'jscpd';
(async () => {
  const clones: IClone[] = await jscpd(['', '', __dirname + '/../fixtures', '-m', 'weak', '--silent']);
  console.log(clones);
})();

detectClones API

import {detectClones} from "jscpd";

(async () => {
  const clones = await detectClones({
    path: [
      __dirname + '/../fixtures'
    ],
    silent: true
  });
  console.log(clones);
})()

detectClones with persist store

import {detectClones} from "jscpd";
import {IMapFrame, MemoryStore} from "@jscpd/core";

(async () => {
  const store = new MemoryStore<IMapFrame>();

  await detectClones({
    path: [
      __dirname + '/../fixtures'
    ],
  }, store);

  await detectClones({
    path: [
      __dirname + '/../fixtures'
    ],
    silent: true
  }, store);
})()

In case of deep customisation of detection process you can build your own tool with @jscpd/core, @jscpd/finder and @jscpd/tokenizer.

Start contribution

  • Fork the repo kucherenko/jscpd
  • Clone forked version (git clone https://github.com/{your-id}/jscpd)
  • Install dependencies (yarn install)
  • Add your changes
  • Add tests and check it with yarn test
  • Create PR

Who uses jscpd

  • GitHub Super Linter is combination of multiple linters to install as a GitHub Action
  • Code-Inspector is a code analysis and technical debt management service.
  • Mega-Linter is a 100% open-source linters aggregator for CI (GitHub Action & other CI tools) or to run locally
  • Codacy automatically analyzes your source code and identifies issues as you go, helping you develop software more efficiently with fewer issues down the line.
  • Natural is a general natural language facility for nodejs. It offers a broad range of functionalities for natural language processing.

Backers

Thank you to all our backers! πŸ™ [Become a backer]

Sponsors

Support this project by becoming a sponsor. Your logo will show up here with a link to your website. [Become a sponsor]

ga tracker

License

MIT Β© Andrey Kucherenko

More Repositories

1

strapi-plugin-passwordless

A plugin for Strapi Headless CMS that provides ability to sign-in/sign-up to an application by link had sent to email.
JavaScript
64
star
2

awesome-project-questions

A list of questions that engineers / architects / managers should ask before the start of a project.
49
star
3

coverage-blamer

coverage-blamer is tool for get information about authors of uncovered code
CoffeeScript
10
star
4

basta

Duplication detection tool (copy-paste detector), support over 150 programming languages
TypeScript
10
star
5

jscpd-badge-reporter

Reporter for jscpd tool, generate badges with information about copy/paste
TypeScript
7
star
6

www.mathrandom.com

www.mathrandom.com
Vue
5
star
7

blamer

blamer is a tool for getting information about author of code from version control system
TypeScript
4
star
8

my-presentations

List of public speaking, trainings, mentoring programs, presentations conducted by me.
4
star
9

tdd-training

TDD Training materials and tests environment setups
JavaScript
3
star
10

caiman

Times series data library. Store data to files or to mongoDB.
JavaScript
3
star
11

Silex-XSLTemplate

XSLTemplate ServiceProvider added support xsl templates to Silex microframework.
PHP
2
star
12

xsltemplate

XSLTemplate is a PHP 5.3 library for processing xsl templates in web projects.
PHP
2
star
13

jscpd-bootstrap-reporter

Starter for jscpd reporter
TypeScript
2
star
14

js-classes

List of tasks for JS+Angular course
JavaScript
2
star
15

odessajs2019-flower-pot-watering

Nest.JS Workshop for OdessaJS 2019
TypeScript
2
star
16

tdd

TypeScript
2
star
17

PredictionIO-JavaScript-SDK

JavaScript
2
star
18

complexml

CompleXml Framework - an open source PHP framework, wide possibilities to optimize the rendering Web pages, including the generation of pages in the user's browser XML + XSL;
PHP
2
star
19

generator-okroshka

generator-okroshka is an easy way to start project with AMD, TDD and BDD.
CoffeeScript
1
star
20

test

1
star
21

tdd-javascript-template

JavaScript
1
star
22

exampleTest

PHP
1
star
23

unittests

Examples for traning about unit tests & TDD in web projects
PHP
1
star
24

xsltemplate.js

xsltemplate.js is a library for xsl transformations in browser and node.js writed on js
JavaScript
1
star
25

card-memory-game

Vue
1
star
26

mongo-todo

Simple todo list writed with Doctrine ODM and MongoDB, based on backbone.js example
JavaScript
1
star