FindBugs is a google project which many of the companies use in their product development lifecycle to findBugs in a java project . Well this can be used as a command line tool or as a plugin to a build automation framework , lets take Gradle for example .
Well findBugs hunts your code very effectively to find stupid coding mistakes which one would not take care of much while coding .
Lets take a look at what does find bug hunt for . Well this is it : BugCodes.
I am not here to talk about findBugs , neither i am here to talk about gradle .
What i am gonna share is how i got messed up with findBugs BugCode : RV .
A situation where i had to ignore the return value of function and also call that function for something to work in background . Well i really got fed up with findBugs to catch my error everytime and keep failing the build.
Well how to supress this warning and go ahead with the build.
-> If you are not a gradle expert do not try this , in build.gradle , in
findbugsMain {
}
you need to give excludeFilter and a file which specifies the format of the classes and the methods and Bug Code to ignore. Well this was a nightmare and i could not achieve it. Check if you can here .
-> Well if you are a java expert which you i hope you are , all you need to do is add this dependecy in your project build file and use the Annotation
@SupressFBWarnings(value = "bug-code") -- well value is an array so you can send in a string array .
OR
if you are not using a build automation framework like ant , maven or gradle , all you need to do is download the annotations.jar from - here and include it in your project library.
Well there you go and you have succeeded in suppressing findBugs warnings and your build has not failed at this point .
Happy Coding
-@nmol
No comments:
Post a Comment