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: 11 days 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: 2024-10-21T04:00:49.000Z (19 days ago)
- Last Synced: 2024-10-24T15:59:27.475Z (15 days ago)
- Topics: clones-detection, code-quality, copy-paste, cpd, detect-duplications, detector, duplicates, duplications, quality
- Language: TypeScript
- Homepage:
- Size: 9.88 MB
- Stars: 4,700
- Watchers: 25
- Forks: 203
- Open Issues: 64
-
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-nodejs-cn - jscpd - **star:4595** 源代码的复制/粘贴检测器 ![star > 2000][Awesome] (包 / 命令行程序)
- 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 - 复制/粘贴检测器以获取源代码. (目录 / 命令行应用)
README
## jscpd
![stand with Ukraine](https://badgen.net/badge/support/UKRAINE/?color=0057B8&labelColor=FFD700)
[![npm](https://img.shields.io/npm/v/jscpd.svg?style=flat-square)](https://www.npmjs.com/package/jscpd)
![jscpd](https://raw.githubusercontent.com/kucherenko/jscpd/master/assets/jscpd-badge.svg?sanitize=true)
[![license](https://img.shields.io/github/license/kucherenko/jscpd.svg?style=flat-square)](https://github.com/kucherenko/jscpd/blob/master/LICENSE)
[![npm](https://img.shields.io/npm/dw/jscpd.svg?style=flat-square)](https://www.npmjs.com/package/jscpd)[![jscpd CI](https://github.com/kucherenko/jscpd/actions/workflows/nodejs.yml/badge.svg)](https://github.com/kucherenko/jscpd/actions/workflows/nodejs.yml)
[![codecov](https://codecov.io/gh/kucherenko/jscpd/branch/master/graph/badge.svg)](https://codecov.io/gh/kucherenko/jscpd)
[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fkucherenko%2Fjscpd.svg?type=shield)](https://app.fossa.io/projects/git%2Bgithub.com%2Fkucherenko%2Fjscpd?ref=badge_shield)
[![Backers on Open Collective](https://opencollective.com/jscpd/backers/badge.svg)](#backers)
[![Sponsors on Open Collective](https://opencollective.com/jscpd/sponsors/badge.svg)](#sponsors)[![NPM](https://nodei.co/npm/jscpd.svg)](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) | [![npm](https://img.shields.io/npm/v/jscpd.svg?style=flat-square)](https://www.npmjs.com/package/jscpd) | main package for jscpd (cli and API for detections included) |
| [@jscpd/core](packages/core) | [![npm](https://img.shields.io/npm/v/@jscpd/core.svg?style=flat-square)](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) | [![npm](https://img.shields.io/npm/v/@jscpd/finder.svg?style=flat-square)](https://www.npmjs.com/package/@jscpd/finder) | detector of duplication in files |
| [@jscpd/tokenizer](packages/tokenizer) | [![npm](https://img.shields.io/npm/v/@jscpd/tokenizer.svg?style=flat-square)](https://www.npmjs.com/package/@jscpd/tokenizer) | tool for tokenize programming source code |
| [@jscpd/leveldb-store](packages/leveldb-store) | [![npm](https://img.shields.io/npm/v/@jscpd/leveldb-store.svg?style=flat-square)](https://www.npmjs.com/package/@jscpd/leveldb-store) | LevelDB store, used for big repositories, slower than default store |
| [@jscpd/html-reporter](packages/html-reporter) | [![npm](https://img.shields.io/npm/v/@jscpd/html-reporter.svg?style=flat-square)](https://www.npmjs.com/package/@jscpd/html-reporter) | Html reporter for jscpd |
| [@jscpd/badge-reporter](packages/badge-reporter) | [![npm](https://img.shields.io/npm/v/@jscpd/badge-reporter.svg?style=flat-square)](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)]
![ga tracker](https://www.google-analytics.com/collect?v=1&a=257770996&t=pageview&dl=https%3A%2F%2Fgithub.com%2Fkucherenko%2Fjscpd&ul=en-us&de=UTF-8&cid=978224512.1377738459&tid=UA-730549-17&z=887657232 "ga tracker")
## License
[MIT](LICENSE) © Andrey Kucherenko