Существует ли способ проигнорировать единственный FindBugs, предупреждающий?

read без любых параметров только продолжится, если Вы нажмете Enter. Команда DOS pause продолжится при нажатии какой-либо клавиши. Используйте read –n1, если Вы хотите это поведение.

183
задан Pang 2 April 2014 в 19:40
поделиться

1 ответ

The FindBugs initial approach involves XML configuration files aka filters. This is really less convenient than the PMD solution but FindBugs works on bytecode, not on the source code, so comments are obviously not an option. Example:

<Match>
   <Class name="com.mycompany.Foo" />
   <Method name="bar" />
   <Bug pattern="DLS_DEAD_STORE_OF_CLASS_LITERAL" />
</Match>

However, to solve this issue, FindBugs later introduced another solution based on annotations (see SuppressFBWarnings) that you can use at the class or at the method level (more convenient than XML in my opinion). Example (maybe not the best one but, well, it's just an example):

@edu.umd.cs.findbugs.annotations.SuppressFBWarnings(
    value="HE_EQUALS_USE_HASHCODE", 
    justification="I know what I'm doing")

Note that since FindBugs 3.0.0 SuppressWarnings has been deprecated in favor of @SuppressFBWarnings because of the name clash with Java's SuppressWarnings.

292
ответ дан 23 November 2019 в 06:01
поделиться
Другие вопросы по тегам:

Похожие вопросы: