Menu

#298 Add comment to trigger FindBugs ignore

3.x
closed-wont-fix
nobody
None
5
2014-11-13
2014-05-19
ASD
No

FindBugs can ignore warnings using annotations. The problem with this approach is that it introduces an unnecessary dependency into the code. It would be nice if there was a //NOFINDBUGS comment to signal to FindBugs to ignore the error the way there is a //NOPMD trigger for PMD.

Discussion

  • Andrey Loskutov

    Andrey Loskutov - 2014-06-19
    • Group: 3.0.0 --> 3.0.1
     
  • Tagir Valeev

    Tagir Valeev - 2014-11-11

    FindBugs is a bytecode scanning tool, so it has its own limitations. Comments never go into .class files, so FindBugs is unable to check them. There are many ways to ignore warnings in FindBugs: annotations, filter files, FindBugs cloud. I think there's no need for one more way.

    Note that if you don't want to have extra dependency, you can define a SuppressFBWarnings annotation anywhere in your project. Just add this annotation class anywhere and use it:

    @Retention(RetentionPolicy.CLASS)
    public @interface SuppressFBWarnings {
        /**
    
         * The set of FindBugs warnings that are to be suppressed in
         * annotated element. The value can be a bug category, kind or pattern.
         *
         */
        String[] value() default {};
    
        /**
    
         * Optional documentation of the reason why the warning is suppressed
         */
        String justification() default "";
    }
    

    FindBugs doesn't care in which package this annotation is defined.

    I guess, this should be closed-wont-fix. Bill, Andrey, what do you think?

     

    Last edit: Tagir Valeev 2014-11-11
  • Tagir Valeev

    Tagir Valeev - 2014-11-11
    • status: open --> open-wont-fix
     
  • Andrey Loskutov

    Andrey Loskutov - 2014-11-11

    I agree.
    Scanning sources for comments would also decrease analysis performance. Also sometimes the warning is placed not where one would expect a comment.
    Regards,
    Andrey

     
  • Tagir Valeev

    Tagir Valeev - 2014-11-13
    • status: open-wont-fix --> closed-wont-fix
     

Log in to post a comment.

MongoDB Logo MongoDB