Skip to content
This repository has been archived by the owner on Jan 4, 2019. It is now read-only.

ModusCreateOrg/jscpd

 
 

Repository files navigation

No longer maintained

[DEPRECATED] This repository is no longer maintained

While this project is fully functional, the dependencies are no longer up to date. You are still welcome to explore, learn, and use the code provided here.

Modus is dedicated to supporting the community with innovative ideas, best-practice patterns, and inspiring open source solutions. Check out the latest Modus Labs projects.

Modus Labs


Copy/paste detector for programming source code.

jscpd is a tool for detect copy/paste "design pattern" in programming source code.

Supported languages
JavaScript Java
CoffeeScript C++
PHP C#
Go Python
Ruby C
Less CSS
SCSS

If you need support language not from list feel free to create request.

Status

Dependency Status Build Status Coverage Status Stories in Ready ![Gitter](https://badges.gitter.im/Join Chat.svg)

NPM NPM

Installation

npm install jscpd -g

Usage

jscpd --path my_project/ --languages javascript,coffee

jscpd -f **/*.js -e **/node_modules/**

jscpd --files **/*.js --exclude **/*.min.js --output report.xml

or

If you have file .cpd.yaml in your directory

#.cpd.yaml
path:
  - fixtures/
languages:
  - javascript
  - coffeescript
  - php
  - python
  - less
  - ruby
  - go
  - java
  - "c++src" # c++ source
  - csrc     # c source
  - csharp   # c# source
exclude:
  - "**/*.min.js"
  - "**/*.mm.js"

and run jscpd command, you will check code for duplicates according config from .cpd.yaml

or

# coffeescript
jscpd = require('jscpd')
result = jscpd::run
    path: 'my/project/folder'
    files: '**/*.js'
    exclude: ['**/*.min.js', '**/node_modules/**']

Please see the minimatch documentation for more details.

Options:

Option Type Default Description
  • -l, --min-lines | [NUMBER] | 5 | min size of duplication in code lines
  • -t, --min-tokens | [NUMBER] | 70 | mim size of duplication in code tokens
  • -f, --files | [STRING] | * | glob pattern for find code
  • -e, --exclude | [STRING] | - | directory to ignore
  • -g, --languages | [STRING] | All supported | list of languages which scan for duplicates, separated with coma
  • -o, --output | [PATH] | - | path to report xml file
  • --verbose    |           | -             | show full info about copies
    
  • -p, --path | [PATH] | Current dir | path to code
  • -d, --debug | | - | show debug information (options list and selected files)
  • -v, --version | | - | Display the current version
  • -h, --help | | - | Display help and usage details

Run tests

  npm test

Changelog

Project changelog

TODO

Project plans

License

The MIT License

Thanks

Thanks to Mathieu Desvé for grunt-jscpd. Thanks to Yannick Croissant for gulp-jscpd. Thanks to linslin for grunt-jscpd-reporter.

Project developed with PyCharm alt pycharm Thanks to JetBrains company for license key. Feel free to contribute this project and you will have chance to get license key too.

About

Copy/paste detector for programming source code.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • CoffeeScript 98.5%
  • JavaScript 1.5%