如何在 Perl 中找到复制/粘贴(重复、克隆)代码?

发布于 2024-08-05 06:46:14 字数 189 浏览 11 评论 0原文

我已经在互联网上搜索了一段时间,但我无法找到任何免费(或便宜)的工具/实用程序/模块可以分析一组 Perl 文件(模块或脚本)并标记重复或克隆或复制/粘贴的代码。

我现在好多了,但我过去常常在各处复制和粘贴代码段。我想清理它并修复我的旧代码重复,但如果有一点工具帮助将不胜感激,这样我就不必仔细检查所有旧代码。另外,手动识别此类违规行为很容易出错。

I've searched the Internet for a while now and I have not been able to find any free (or cheap) tools/utilities/modules that can analyze a set of Perl files (modules or scripts) and flag duplicate or cloned or copy/pasted code.

I'm better now, but I used to copy and paste sections of code all over the place. I'd like to clean it up and fix my old code duplication, but a little bit of tool help would be appreciated so I won't have to go through all my old code with a fine tooth comb. Plus, manual recognition of this sort of offense is error prone.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

情场扛把子 2024-08-12 06:46:15

我刚刚评估了 Simian。它有 15 天的免费评估期,单个用户许可证的费用为 100 美元。它并不正式支持 Perl,但它确实将它们视为纯文本并无论如何分析它们。这是一个超级快速的实用程序!而且超级容易使用。该工具生成的报告简单且易于解释。我完全认可这个工具。现在我只需要和我的老板谈谈并让他购买许可证。

I just evaluated Simian. It has a 15 day free evaluation period and costs a hundred bucks for a single user license. It doesn't officially support Perl, but it does treat them as plain text and analyzes them anyways. This is a super fast utility! And super easy to use. The report generated from this tool was simple and easy to interpret. I totally approve of this tool. Now I just need to talk to my boss and get him to purchase a license.

虫児飞 2024-08-12 06:46:15

这是另一个网页,列出了一些克隆检测工具:

http: //sel.ics.es.osaka-u.ac.jp/cdtools/index-e.html

Here's another web page listing some clone detection tools:

http://sel.ics.es.osaka-u.ac.jp/cdtools/index-e.html

别再吹冷风 2024-08-12 06:46:14

有趣的是,几分钟前,一个类似问题被发布到了SO。

以下是一些您可能会觉得有用的工具的链接。

代码比较和抄袭检测

Funny a similar question was posted to SO just a few minutes ago.

Here is a link with some tools you may find useful.

Code Comparison and Plagirism Detection

硬不硬你别怂 2024-08-12 06:46:14

重复代码是什么意思?只是字符完全匹配或语义匹配。

有几种工具,例如 http://pmd.sourceforge.net/ 可以通过字符串匹配来检测重复代码,该工具适用于 java,但源匹配适用于纯文本。

如果你想要语义匹配,喜欢

sub A
{return 1;}

匹配

sub B
{
    return 1;
}

那么你需要别的东西:(

What do you mean by duplicate code? Just character exact matches or semantic matches.

There are several tools like http://pmd.sourceforge.net/ that can detect duplicate code by string matches, this tool is for java but the source matching works on plain text.

If you want semantic matching, like

sub A
{return 1;}

to match

sub B
{
    return 1;
}

Then you'll need something else:(

滥情稳全场 2024-08-12 06:46:14

我过去曾使用 CCFinder 来查找重复的代码部分。它工作得很好,但有一个..有趣的界面。它没有对 perl 的本机支持,但它有一个纯文本选项,至少应该可以用于检测复制和粘贴。有一个 Windows 和 Ubuntu 解决方案 - 免费软件,不幸的是不是开源的。

I have used CCFinder in the past to find sections of code which are duplicates. It works quite well but has an.. interesting interface. It doesn't have native support for perl, but it does have a plaintext option which should work for detection of copy and pasting at least. There is a Windows and Ubuntu solution - Freeware, not open source unfortunately.

魂ガ小子 2024-08-12 06:46:14

Semantic Designs 推出了一款名为 Clone Dr. 的产品,该产品似乎能够分析大量数据克隆代码部分的语言类型。但他们的免费评估版似乎仅适用于 Java 和 Cobol。

Semantic Designs makes a product called Clone Dr. that appears to be able to analyze a large number of language types for cloned sections of code. But it appears that their free evaluation version only works on Java and Cobol.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文