Java / Eclipse:删除“不必要的@SuppressWarnings”的多个警告;

发布于 2024-11-25 23:00:21 字数 280 浏览 1 评论 0原文

我正在开发一个遗留的 Java 应用程序,它有大约 6k 条警告,我正在尝试清理它们。其中之一就是“不必要的@Suppresswarnings('XXXX')”。 Eclipse对此有一个快速修复,但代码库中有数百个,甚至更多的实例实际使用它。

我希望能够立即对所有这些警告应用“快速修复”(删除未使用的令牌),但似乎找不到实现这一目标的方法。由于使用此注释的许多(更多)实例不会生成警告,因此强力删除注释只会创建更多警告。

有没有办法在 eclipse (或者可能是第三方工具)中执行此操作,或者我只是运气不好?

I'm working on a legacy Java App that has about 6k warnings that I am trying to clean up. One of them is simply "Unnecessary @Suppresswarnings('XXXX')". Eclipse has a quick fix for this, but there are several hundred in the codebase, and even more instances where it is actually used.

I would like to be able to apply the "Quick Fix" (remove unused tokens), on all these warnings at once, but can't seem to find a way to make that happen. Since there are many (more) instances of this annotation being used that aren't generating warnings, a brute-force strip of the annotations would just create more warnings.

Is there a way to do this in eclipse (or maybe a third-party tool), or am I just out of luck with this?

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

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

发布评论

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

评论(2

初见 2024-12-02 23:00:21

我很愿意错,但我认为你运气不好。我知道没有办法立即对多个警告进行快速修复。

I would love to be wrong but I think you're out of luck. I know of no way to apply a quick fix to multiple warnings at once.

分开我的手 2024-12-02 23:00:21

最好的选择是在 Eclipse 之外执行此操作。也许使用 sed / awk 的快速 shell 脚本就足够了?如果您有复杂的规则,您总是可以编写另一个 Java 程序来剥离内容。

Your best bet is to do this outside of Eclipse. Maybe a quick shell script with sed / awk would be enough? If you have complicated rules, you could always write another Java program to strip things out.

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