Tips to show similarities in files

我是研究僧i 提交于 2019-12-21 04:13:04

问题


In a project, I found some css files that "smell" like there are copy-pasted rules in them.

I wonder what are your strategies for detecting copy-paste stuff in files.

Just of curiosity i'd like to hear your tips and tricks for showing file similarities!


回答1:


Try Simian.

It is used for copy-paste-detection in source code (Java, C#, C, C++, COBOL, Ruby, JSP, ASP, HTML, XML, Visual Basic, Groovy), but you can run this on plain text files too.




回答2:


There is a Copy-Paste Detection (CPD) project on sourceforge; http://pmd.sourceforge.net/cpd.html

But even in large projects I find my own knowledge of the code to be a reliable (although not foolproof) detection mechanism.

Also see this question for other suggestions.




回答3:


Our Semantic Designs CloneDR is a tool that detects copy-paste-edit blocks of code, for many languages: C, C++, Java, C++, COBOL, ECMAScript, PHP, VB6, VB.net, ...

It does using language-accurate parsers to build abstract syntax trees, corresponding to exact program structures, which are then compared for similarity. This means it is not confused in any way by whitespace, formmatting, comments, or even different "spelling" of literals (e.g., 3.14159 is the same as .00314150E3).

It generates a report that shows exactly how the blocks of code are similar, and precisely how they vary. You can see sample reports at the link.



来源:https://stackoverflow.com/questions/1536643/tips-to-show-similarities-in-files

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!