Coder Social home page Coder Social logo

istro / jscpd Goto Github PK

View Code? Open in Web Editor NEW

This project forked from kucherenko/jscpd

0.0 2.0 0.0 204 KB

Copy/paste detector for programming source code.

Home Page: https://github.com/kucherenko/jscpd

License: MIT License

JavaScript 1.92% Shell 0.66% CoffeeScript 97.42%

jscpd's Introduction

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 Mixed HTML
TypeScript

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

jscpd --files **/*.js --exclude **/*.min.js --reporter json --output report.json

or

If you have file .cpd.yaml in your directory

#.cpd.yaml
path:
  - fixtures/
languages:
  - javascript
  - coffeescript
  - typescript
  - php
  - python
  - css
  - ruby
  - go
  - java
  - "c++src"    # c++ source
  - csrc        # c source
  - csharp      # c# source
  - htmlmixed   # html mixed source like knockout.js templates
exclude:
  - "**/*.min.js"
  - "**/*.mm.js"
reporter: json

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/**']
  reporter: json

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 | min size of duplication in code tokens
  • -f, --files | [STRING] | * | glob pattern for find code
  • -r, --reporter | [STRING] | xml | reporter name or path
  • -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 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

Reporters

jscpd shipped with two standard reporters xml and json. It is possible to write custom reporter script too. For hooking reporter up wrap it into node module and provide path to it as reporter parameter e.g. ./scripts/jscpd-custom-reporter.coffee (works with javascript too).

Custom reporter is a function which is executed into context of Report (report.coffee) class and thus has access to the report object and options. Expected output is array with following elements:

[raw, dump, log]

  • raw is raw report object which will be passed through.
  • dump is report which will be written into output file if any provided.
  • log custom log output for cli.

At least one of raw or dump needs to be provided, log is fully optional.

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.

jscpd's People

Contributors

kucherenko avatar dmi3y avatar avgerin0s avatar bitdeli-chef avatar titarenko avatar emmanueldemey avatar golmansax avatar gitter-badger avatar darthwade avatar waffle-with-pears avatar

Watchers

Ivan Stroganov avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.