Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Copy/paste detector for programming source code.

License

NotificationsYou must be signed in to change notification settings

kucherenko/jscpd

Repository files navigation

jscpd

stand with Ukraine

npmjscpdlicensenpm

jscpd CIcodecovFOSSA StatusBackers on Open CollectiveSponsors 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 implementsRabin-Karp algorithm for searching duplications.

Packages of jscpd

nameversiondescription
jscpdnpmmain package for jscpd (cli and API for detections included)
@jscpd/corenpmcore detection algorithm, can be used for detect duplication in different environments, one dependency to eventemitter3
@jscpd/findernpmdetector of duplication in files
@jscpd/tokenizernpmtool for tokenize programming source code
@jscpd/leveldb-storenpmLevelDB store, used for big repositories, slower than default store
@jscpd/html-reporternpmHtml reporter for jscpd
@jscpd/badge-reporternpmBadge 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 clihere.

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';constclones:Promise<IClone[]>=jscpd(process.argv);

jscpd async/await API

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

detectClones API

import{detectClones}from"jscpd";(async()=>{constclones=awaitdetectClones({path:[__dirname+'/../fixtures'],silent:true});console.log(clones);})()

detectClones with persist store

import{detectClones}from"jscpd";import{IMapFrame,MemoryStore}from"@jscpd/core";(async()=>{conststore=newMemoryStore<IMapFrame>();awaitdetectClones({path:[__dirname+'/../fixtures'],},store);awaitdetectClones({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 repokucherenko/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 withpnpm test
  • Build your projectpnpm build
  • 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


[8]ページ先頭

©2009-2025 Movatter.jp