Currently SIC_INNER_SHOULD_BE_STATIC_ANON warning is annotated with anonymous class name only which is not very user-friendly and limits the ability to suppress warnings. See, for example, this StackOverflow question.
Consider the following code:
@SuppressFBWarnings("SIC")
private final ThreadLocal<Integer> myField=new ThreadLocal<Integer>() {
@Override
protected Integer initialValue() {
return 0;
}
};
@SuppressFBWarnings("SIC")
public void test() {
ThreadLocal<Integer> myLocal=new ThreadLocal<Integer>() {
@Override
protected Integer initialValue() {
return 0;
}
};
}
The expected behavior is that SIC_INNER_SHOULD_BE_STATIC_ANON is suppressed in both cases, so we need to include into the bug annotation the field to which anonymous class instance is assigned and the method where it's used. Having the local variable name (myLocal) would also be nice.
Fixed: https://github.com/findbugsproject/findbugs/commit/6c91c0c5e3a0bc017ee7d850fdf556776254b7f2