Java / Eclipse:删除“不必要的@SuppressWarnings”的多个警告;
我正在开发一个遗留的 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我很愿意错,但我认为你运气不好。我知道没有办法立即对多个警告进行快速修复。
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.
最好的选择是在 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.