Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kucherenko/jscpd
Copy/paste detector for programming source code.
https://github.com/kucherenko/jscpd
clones-detection code-quality copy-paste cpd detect-duplications detector duplicates duplications quality
Last synced: about 22 hours ago
JSON representation
Copy/paste detector for programming source code.
- Host: GitHub
- URL: https://github.com/kucherenko/jscpd
- Owner: kucherenko
- License: mit
- Created: 2013-05-29T06:19:20.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2025-02-07T18:22:16.000Z (11 days ago)
- Last Synced: 2025-02-08T03:32:53.835Z (11 days ago)
- Topics: clones-detection, code-quality, copy-paste, cpd, detect-duplications, detector, duplicates, duplications, quality
- Language: TypeScript
- Homepage:
- Size: 9.54 MB
- Stars: 4,765
- Watchers: 24
- Forks: 208
- Open Issues: 70
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: .github/CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
- Support: supported_formats.md
Awesome Lists containing this project
- awesome-nodejs-cn - jscpd - 源代码重复代码检测 (包 / 命令行程序)
- awesome-github-star - jscpd
- awesome-list - jscpd
- awesome-nodejs - jscpd - Copy/paste detector for source code. (Packages / Command-line apps)
- awesome-web-dev - jscpd
- awesome-nodejs - jscpd - Copy/paste detector for programming source code. - ★ 855 (Command-line apps)
- made-in-ukraine - jscpd
- awesome-node - jscpd - Copy/paste detector for source code. (Packages / Command-line apps)
- awesome-nodejs-cn - jscpd - 复制/粘贴检测器以获取源代码. (目录 / 命令行应用)
- stars - jscpd
- stars - jscpd
- awesome-nodejs-cn - jscpd - **star:4770** 源代码的复制/粘贴检测器 ![star > 2000][Awesome] (包 / 命令行程序)
README
![]()
## jscpd

[](https://www.npmjs.com/package/jscpd)

[](https://github.com/kucherenko/jscpd/blob/master/LICENSE)
[](https://www.npmjs.com/package/jscpd)[](https://github.com/kucherenko/jscpd/actions/workflows/nodejs.yml)
[](https://codecov.io/gh/kucherenko/jscpd)
[](https://app.fossa.io/projects/git%2Bgithub.com%2Fkucherenko%2Fjscpd?ref=badge_shield)
[](#backers)
[](#sponsors)[](https://nodei.co/npm/jscpd/)
> 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](https://en.wikipedia.org/wiki/Rabin%E2%80%93Karp_algorithm) algorithm for searching duplications.## Packages of jscpd
| name | version | description |
|----------------------|----------|---------------|
| [jscpd](apps/jscpd) | [](https://www.npmjs.com/package/jscpd) | main package for jscpd (cli and API for detections included) |
| [@jscpd/core](packages/core) | [](https://www.npmjs.com/package/@jscpd/core) |core detection algorithm, can be used for detect duplication in different environments, one dependency to eventemitter3 |
| [@jscpd/finder](packages/finder) | [](https://www.npmjs.com/package/@jscpd/finder) | detector of duplication in files |
| [@jscpd/tokenizer](packages/tokenizer) | [](https://www.npmjs.com/package/@jscpd/tokenizer) | tool for tokenize programming source code |
| [@jscpd/leveldb-store](packages/leveldb-store) | [](https://www.npmjs.com/package/@jscpd/leveldb-store) | LevelDB store, used for big repositories, slower than default store |
| [@jscpd/html-reporter](packages/html-reporter) | [](https://www.npmjs.com/package/@jscpd/html-reporter) | Html reporter for jscpd |
| [@jscpd/badge-reporter](packages/badge-reporter) | [](https://www.npmjs.com/package/@jscpd/badge-reporter) | Badge reporter for jscpd |## Installation
```bash
$ npm install -g jscpd
```
## Usage
```bash
$ npx jscpd /path/to/source
```
or```bash
$ jscpd /path/to/code
```
or```bash
$ jscpd --pattern "src/**/*.js"
```
More information about cli [here](apps/jscpd).## Programming API
For integration copy/paste detection to your application you can use programming API:
`jscpd` Promise API
```typescript
import {IClone} from '@jscpd/core';
import {jscpd} from 'jscpd';const clones: Promise = jscpd(process.argv);
````jscpd` async/await API
```typescript
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
```typescript
import {detectClones} from "jscpd";(async () => {
const clones = await detectClones({
path: [
__dirname + '/../fixtures'
],
silent: true
});
console.log(clones);
})()
````detectClones` with persist store
```typescript
import {detectClones} from "jscpd";
import {IMapFrame, MemoryStore} from "@jscpd/core";(async () => {
const store = new MemoryStore();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](https://github.com/kucherenko/jscpd/)
- Clone forked version (`git clone https://github.com/{your-id}/jscpd`)
- Install dependencies (`pnpm install`)
- Run the project in dev mode: `pnpm dev` (watch changes and rebuild the packages)
- Add your changes
- Add tests and check it with `pnpm test`
- Build your project `pnpm build`
- Create PR## Who uses jscpd
- [GitHub Super Linter](https://github.com/github/super-linter) is combination of multiple linters to install as a GitHub Action
- [Code-Inspector](https://www.code-inspector.com/) is a code analysis and technical debt management service.
- [Mega-Linter](https://nvuillam.github.io/mega-linter/) is a 100% open-source linters aggregator for CI (GitHub Action & other CI tools) or to run locally
- [Codacy](http://docs.codacy.com/getting-started/supported-languages-and-tools/) automatically analyzes your source code and identifies issues as you go, helping you develop software more efficiently with fewer issues down the line.
- [Natural](https://github.com/NaturalNode/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](https://opencollective.com/jscpd#backer)]
Support this project by becoming a sponsor. Your logo will show up here with a link to your website. [[Become a sponsor](https://opencollective.com/jscpd#sponsor)]

## License
[MIT](LICENSE) © Andrey Kucherenko