在IntelliJ中查找未使用的方法(不包括测试) [英] Finding unused methods in IntelliJ (excluding tests)

查看:149
本文介绍了在IntelliJ中查找未使用的方法(不包括测试)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我今天碰到了一个方法,但是没有在任何地方使用..但是经过测试。由于测试使用它, IntelliJ 没有将方法标记为'未使用'。

I ran into a method today that is .. not used anywhere .. but is tested. Since it is used by a test, IntelliJ did not flag the method as 'unused'.

是否 IntelliJ 允许以下搜索条件查找除测试之外未使用的方法,其中test定义为 @Test 注释

Does IntelliJ allow for the following search condition "Find methods that are unused with the exception of tests, where test is defined as anything with @Test annotation"

推荐答案

有相关的功能请求:


  • IDEA-56519 检查未使用的代码需要采取的选项考虑到由测试工具运行的方法

  • IDEA-56519 Inspection for unused code needs options to take into account methods run by test harnesses

虽然配置注释已经涵盖了第一点...... 检查设置中的选项,第二个点仍然有效:

While the first point is already covered by the Configure annotations... option in the inspection settings, the second point is still valid:


一个选项,使得测试方法(如上所述)不是被认为是一个切入点。这样我们就可以消除仅由测试方法使用的生产方法。

An option such that a test method (as described above) is not considered an entry point. This is so that we can eliminate ‘production’ methods that are only used by test methods.

这篇关于在IntelliJ中查找未使用的方法(不包括测试)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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