Menu

#1418 Improve annotation of SIC_INNER_SHOULD_BE_STATIC_ANON

3.0.2
closed-fixed
None
5
2015-10-04
2015-09-07
No

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.

Discussion

  • Tagir Valeev

    Tagir Valeev - 2015-10-04
    • status: open --> closed-fixed
     

Log in to post a comment.

MongoDB Logo MongoDB