GithubHelp home page GithubHelp logo

copypastedetector's Introduction

CopyPasteDetector

简介

检测项目中的重复代码,原理参考了 PMD 工具的 CPD 部分 。由于 IntelliJ IDEA 等开发工具和 PMD 等分析工具已经包含了重复代码检测的功能,本项目的实际使用意义不大。

运行方法

将该项目作为 Maven 项目导入到 IDE 中,在 CPDLauncher 中设置参数,然后运行。

原理

CPD 原理: PMD 源码阅读(2)— 复制粘贴检测

检测过程主要分为三个步骤:

1. 对代码文件进行分词。

本项目中使用 ANTLR v4 生成的 Lexer 进行分词。
使用的语法文件: antlr/grammars-v4

2. 使用Rabin-Karp查找重复的代码片段对。

算法参考: Rabin-Karp的Java实现

3. 将两两重复的多段代码片段合并到一起。

copypastedetector's People

Contributors

suziquan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

starymz

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.