简体   繁体   English

如何在不从 Eclipse 中得到警告的情况下抑制容易出错的警告?

[英]How to suppress errorprone warnings without getting a warning from eclipse?

I wonder if it's possible to locally suppress errorprone warnings without getting an Eclipse warning instead.我想知道是否有可能在本地抑制容易出错的警告而不会收到 Eclipse 警告。 For example, with this line例如,用这条线

private final byte[] magicBytes;

in an enum, I get the ImmutableEnumChecker warning as byte[] is mutable.在枚举中,我收到ImmutableEnumChecker警告,因为byte[]是可变的。 This makes sense, but I ensured that it never leaks and never gets mutated, so I'd like to suppress the warning here.这是有道理的,但我确保它永远不会泄漏并且永远不会发生变异,所以我想在这里取消警告。 I don't want to suppress it globally, so I can't use the command line parameters and with我不想全局抑制它,所以我不能使用命令行参数和

@SuppressWarnings("ImmutableEnumChecker")

I only trade the errorprone warning for the Eclipse warning Unsupported @SuppressWarnings("ImmutableEnumChecker") .我只将容易出错的警告换成 Eclipse 警告Unsupported @SuppressWarnings("ImmutableEnumChecker")

Before, I used to use findbugs which has @SuppressFBWarnings for this very reason....之前,我曾经因为这个原因使用带有@SuppressFBWarnings findbugs....

Is there something like "SuppressFBWarnings" in errorprone?有没有像“SuppressFBWarnings”这样容易出错的东西? Or any other solution?还是有其他解决办法?

There is an option in eclipse to supress the @SuppressWarnings("ImmutableEnumChecker") annotation. eclipse 中有一个选项可以抑制 @SuppressWarnings("ImmutableEnumChecker") 注释。 Go to Settings -> Java -> Compiler -> Errors/Warnings -> Annotations -> Unhandled Token in '@SuppressWarnings' and set it to ignore.转到“设置”->“Java”->“编译器”->“错误/警告”->“注释”->“@SuppressWarnings”中的未处理令牌并将其设置为忽略。

Additionally there are bug/feature reports for eclipse where you can vote/contribute:此外,还有 eclipse 的错误/功能报告,您可以在其中投票/贡献:

https://bugs.eclipse.org/bugs/show_bug.cgi?id=392045 https://bugs.eclipse.org/bugs/show_bug.cgi?id=392045

https://bugs.eclipse.org/bugs/show_bug.cgi?id=122475 https://bugs.eclipse.org/bugs/show_bug.cgi?id=122475

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM