是否有任何工具可以检测不再使用的代码/功能? [英] Is there any tool to detect code/functionality which is no longer used?

查看:145
本文介绍了是否有任何工具可以检测不再使用的代码/功能?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有许多应用程序正在运行(考虑所有这些应用程序都在Java平台上运行),我们需要检查哪些应用程序在最后一个月,比如说3个月,以及在这些活动应用程序中使用哪些部件/功能(以及如何使用)经常)仍然在使用。这可能吗?

We have many applications running (consider all of them run on Java Platform) and we need to check which ones were used in the last, say, 3 months, and, among those active applications, which parts/functionalities (and how often) are still being used. Is that possible?

这里的目标是检测不再与业务相关的应用程序或功能并删除它们,这样我们最终可以维护更少的代码和监视器。

The goal here is to detect applications or funcionalities which no longer are relevant to the business and remove them, so that we end up having less code to maintain and monitor.

是否有任何工具可以帮助我们实现这一目标?

Is there any tool which could help us achieving that?

我们使用敏捷方法,因此当新应用程序投入生产时,它只具有对业务很重要的功能,但有时这个应用程序的某些功能会过期(出于不同的原因),所以我们希望有一种识别方法。

We DO use agile methods, so when a new application gets into production it has only the funcionalities which are important to the business, but sometimes some features of this application expires (for different reasons), so we would like to have a way of identifying that.

推荐答案

您可以在应用程序中部署至少两个工具并收集一些统计信息,甚至在生产中:

There are at least two tools you can deploy along your application and collect some statistics, even in production:


  1. AspectJ - 编织所有类并以某种方式记录每个方法的执行。

  1. AspectJ - weave all classes and somehow log every method execution.

JaCoCo - 基本上做同样的事情,但在Java代理的帮助下自动执行。执行的方法/分支(实际上,这是一个代码覆盖工具)保存在文件中以供将来处理。应该很容易解决你的问题。

JaCoCo - essentially does the same thing but automatically with a help of a Java agent. Executed methods/branches (in fact, this is a code coverage tool) are saved in a file for future processing. Should solve your problem pretty easy.

这两种方法都适用于任何JVM语言(我看到 jruby 的问题)因为它们在字节码级别上工作。我曾经在Selenium测试运行期间使用JaCoCo测量代码覆盖率(想一想:哪些方法/分支被执行)。

Both approaches should work with any JVM language (I see jruby in your question) as they work on bytecode level. I once used JaCoCo to measure code coverage (think: which methods/branches were execured) during Selenium test run.

这篇关于是否有任何工具可以检测不再使用的代码/功能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆