是否有一个自动工具可以检测代码库的干燥程度?

发布于 2024-12-21 13:09:06 字数 213 浏览 1 评论 0原文

我是DRY 原则的坚定拥护者:

每条知识都必须在系统内有一个单一的、明确的、权威的表示。

是否有任何工具可以测试代码库的干燥程度,并量化和查明具体的纠正示例?

I am a strong advocate of the DRY principle:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

Are there any tools that can test a code base for the amount of DRYness and both quantify and pinpoint specific examples for correction?

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

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

发布评论

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

评论(4

调妓 2024-12-28 13:09:06

Simian

Simian(相似性分析器)识别 Java、C#、C、
C++、COBOL、Ruby、JSP、ASP、HTML、XML、Visual Basic、Groovy 源
代码甚至纯文本文件。事实上,simian 可以用于任何
人类可读的文件,例如 ini 文件、部署描述符、
命名它。

Simian 可在任何 .NET 1.1 或更高版本支持的环境中本机运行
并且在任何 Java 5 或更高版本的虚拟机上,这意味着 Simian 可以运行
几乎可以在您希望的任何硬件和操作系统上使用。
Java 和 .NET 运行时都包含在
分布。

Simian

Simian (Similarity Analyser) identifies duplication in Java, C#, C,
C++, COBOL, Ruby, JSP, ASP, HTML, XML, Visual Basic, Groovy source
code and even plain text files. In fact, simian can be used on any
human readable files such as ini files, deployment descriptors, you
name it.

Simian runs natively in any .NET 1.1 or higher supported environment
and on any Java 5 or higher virtual machine, meaning Simian can be run
on just about any hardware and any operating system you can hope for.
Both the Java and .NET runtimes are included as part of the
distribution.

念﹏祤嫣 2024-12-28 13:09:06

PMD 的复制过去检测器 (CPD)

重复的代码可能很难找到,尤其是在大型项目中。但
PMD 的复制/粘贴检测器 (CPD) 可以为您找到它!

请注意,CPD 适用于 Java、JSP、C、C++、Fortran 和 PHP 代码。

您可以通过命令行运行它,有一个 ANT 任务和一个 Eclipse 插件。

PMD's Copy Past Detector (CPD)

Duplicate code can be hard to find, especially in a large project. But
PMD's Copy/Paste Detector (CPD) can find it for you!

Note that CPD works with Java, JSP, C, C++, Fortran and PHP code.

You can run it commandline, there is an ANT task, and an Eclipse plugin.

落花随流水 2024-12-28 13:09:06

Visual Studio 克隆侦探

Clone Detective 是一个 Visual Studio 集成,可让您
分析 C# 项目中在其他地方重复的源代码。
重复很容易导致不一致,并且通常是一个问题
分解不良代码的指示器。

在此处输入图像描述

Clone Detective for Visual Studio

Clone Detective is a Visual Studio integration that allows you to
analyze C# projects for source code that is duplicated somewhere else.
Having duplicates can easily lead to inconsistencies and often is an
indicator for poorly factored code.

enter image description here

静若繁花 2024-12-28 13:09:06

请参阅我们的 CloneDR 工具,该工具使用计算机语言结构作为指导来查找精确的和几乎未命中的重复代码集。除了检测克隆之外,它还将向您展示粗略的抽象和解释克隆实例之间差异的参数绑定。

它具有多种语言的实例化:C、C++、C#、Java、JavaScript、PHP、COBOL、Python、PLSQL...它往往会在任何规模较大的系统(例如 100K SLOC)中发现 10-15% 的重复代码及以上)。该网站上有多种语言的示例报告,您可以下载试用版。

See our CloneDR tool, which finds exact and near miss sets of duplicated code using computer langauge structure as guide. As well as detecting clones, it will show you a rough abstraction and the parameter bindings that explain the differences between the clone instances.

It has instantiations for many lanuages: C, C++, C#, Java, JavaScript, PHP, COBOL, Python, PLSQL, ... It tends to find 10-15% duplicated code across systems that have any serious size (e.g, 100K SLOC and above). There are sample reports for many languages at the web site, and you can download a trial copy.

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