Suppress FindBugs Warnings in a Java and Spring Boot Web Application using Gradle

How to Suppress FindBugs Warnings using Annotations in a +Spring Boot and +Java Application



If your build is breaking because of a FindBugs issue and it is a false-positive or you are unable to resolve the issue because of other considerations, you can add an Annotation to ignore the Findbugs warning.


Update your Gradle Dependencies


You will want to add the following compile time dependency to your build.gradle file.

compile group: 'findbugs', name: 'findbugs', version: '1.0.0'

dependencies {

    compile group: 'findbugs', name: 'findbugs', version: '1.0.0'
}


Get the Findbugs Issue ID

You will need a specific ALL_CAPS identifier so that FindBugs knows what bug to ignore.


Locate the FindBugs Report


In your build message, you will see a link to the findbugs report:



You can also find the report in your build artifact.  Right-click and open in your preferred browser to view file.
find bugs html report in build artifact
Open the findbugs html report from the build directory


Open the FindBugs Report


Once you have it, open the Findbugs HTML report in a browser.  It should look like the following.

findbugs html report for java issues
Find Bugs HTML Report

Get the FindBugs identifier


Copy and paste the FindBugs identifier.  It should be in ALL_CAPS.

You will use the annotation like this:
@SuppressWarnings("OUT_OF_RANGE_ARRAY_INDEX")

Add the Annotation to Your Code


Be sure that the correct findbugs SuppressWarnings annotation is being used.

import edu.umd.cs.findbugs.annotations.SuppressWarnings;


Add Suppress warnings annotation


Add this Suppress warnings annotation above the offending line of code.  There are multiple versions of this annotation.

Be sure to use the specific FindBugs issue ID as a parameter in the annotation.


Be sure to use the annotation specific to findbugs in the package edu.umd.cs.findbugs.annotations.

Suppress warnings annotation
Use the edu.umd.cs.findbugs.annotation version of @SuppressWarnings


This is the annotation you will want to add above the offending line of code.

@SuppressWarnings("OUT_OF_RANGE_ARRAY_INDEX")



Re-run the Build to Verify that the Warning is being Suppressed


You want to ensure that the warning is being ignored correctly.  You may want to add a TODO as well if you intend to fix the issue at a later point as well or at least track the issues you are suppressing in some way.

Your build should run successfully without issuesmoving forward now.



Further info:




Comments

  1. Thanks for sharing this information with us and it was a nice blog.
    AWS Cloud Support in Delhi

    ReplyDelete
  2. Very nice post here thanks for it .I always like and such a super contents of these
    post.Excellent and very cool idea and great content of different kinds of the valuable
    information's
    Server Management Company in Delhi
    Live Streaming Company in Delhi
    seo company in delhi

    ReplyDelete
  3. smart outsourcing solutions is the best outsourcing training
    in Dhaka, if you start outsourcing please
    visit us: Freelancing training in bangladesh
    Outsourcing training in dhaka
    Outsourcing training in bangladesh

    ReplyDelete
  4. Hi, Amazing you know this article is helping for me and everyone and thanks for sharing information.
    JavaScript Training Course in Delhi

    ReplyDelete
  5. This comment has been removed by the author.

    ReplyDelete
  6. Thanks for sharing Blog. This Blog is very Helpful. Gnec Media is a leading website design, web development company in Delhi offer custom website development services.


    Web Development Services in Delhi

    ReplyDelete
  7. If you are looking for Apps that are comprehensive, high on visual appeal, intelligent, responsive, and engaging, We are the leading mobile app development company in the UK.

    ReplyDelete
  8. Very useful code for all startups. Please check our new website for best and more informative article Audit firms in dubai
    Economic Substance Dubai

    ReplyDelete
  9. We are well established IT and outsourcing firm working in the market since 2013. We are providing training to the people ,
    like- Web Design , Graphics Design , SEO, CPA Marketing & YouTube Marketing.Call us Now whatsapp: +(88) 01537587949
    : Digital marketing training
    Free bangla sex video:careful
    good post Freelancing Training in bangladesh

    ReplyDelete
  10. Thanks for Sharing This Article.It is very so much valuable content.
    DevOps Training
    DevOps Online Training

    ReplyDelete
  11. Thanks for Sharing This Article.It is very so much valuable content. I hope these Commenting lists will help to my website
    devops online training
    best devops online training
    top devops online training

    ReplyDelete
  12. Enjoyed reading your blog. Please check my latest post on the chartered accountant in Dubai  and let me know what you think.

    ReplyDelete
  13. Superb explanation & it's too clear to understand the concept as well, keep sharing admin with some updated information with right examples. Keep update more posts. Nice Article! Thanks for sharing such amazing information.
    SEO Company
    Digital Marketing Service
    Digital Marketing company in Delhi

    ReplyDelete
  14. You want to ensure that the warning is being ignored correctly. You may want to add a TODO as well if you intend to fix the issue at a later point as well or at least track the issues you are suppressing in some way. lawn suits with chiffon dupatta , 2 piece suit online shopping in pakistan

    ReplyDelete
  15. Tecocraft is a renowned mobile app development agency in the US, providing world-class mobile app development services to worldwide clients at affordable prices. Tecocraft holds a proficient team of talented mobile app developers who have expertise in creating functionality-rich, feature-loaded, and scalable Android/iOS mobile applications to let your business portable on mobile. Our dedicated mobile app developers make use of cutting-edge technologies and advanced tools by choosing the right development frameworks based on your custom business requirements.

    ReplyDelete
  16. Thanks For Sharing such a wonderful article the way you presented is really amazing
    Best Software Training Institutes

    ReplyDelete
  17. We are leading significant entrepreneurs and businesses to help in market transformation. We see that potential in your blog post. Contact AppSquadz to know more about such opportunities. Also visit: mobile app development company

    ReplyDelete
  18. Thanks for your information is so helpful, and your personal comments are so easy to follow.
    textspeed

    ReplyDelete
  19. The Vidmate app is a three-in-one utility for playing, downloading, and converting videos. It works with hundreds of streaming websites to provide access to a massive content library for free viewing.

    Easy access to HD videos
    Vidmate is an app that enables free and quick content downloads from video streaming sites all over the Internet.
    Vidmate is primarily a video downloader that offers easy-to-use tools for browsing and downloading media. It covers streaming sites such as Vevo and YouTube, as well as social media.

    The UI is quite straightforward. It shows you supported websites for you to choose and find and download the content you want with a single click.

    download vidmate apk
    Techisq free app download
    free mobile app download
    9app software
    Vidmate latest version
    leaked movies download
    latest version vidmate
    free video vidmate
    Job apps work from home jobs

    ReplyDelete
  20. The Vidmate app is a three-in-one utility for playing, downloading, and converting videos. It works with hundreds of streaming websites to provide access to a massive content library for free viewing.

    Easy access to HD videos
    Vidmate is an app that enables free and quick content downloads from video streaming sites all over the Internet.
    Vidmate is primarily a video downloader that offers easy-to-use tools for browsing and downloading media. It covers streaming sites such as Vevo and YouTube, as well as social media.

    The UI is quite straightforward. It shows you supported websites for you to choose and find and download the content you want with a single click.

    download vidmate apk
    Techisq free app download
    free mobile app download
    9app software
    Vidmate latest version
    leaked movies download
    latest version vidmate
    free video vidmate
    Job apps work from home jobs
    Report: Your phone number reveals more personal info than your name
    According to a recent New York Times article, your phone number has loads of personal information attached to it. Quite often, websites and apps ask us for our phone number when logging in or creating an account.

    ReplyDelete
  21. I'm reading a blog on this website for the first time, and I'd like to commend you on the high quality of the content. It's quite well-written. Thank you so much for posting this blog; I will definitely read all of your future writings.

    photographers in Andaman
    photoshoot in havelock Andaman
    photoshoot in Andaman
    pre wedding shoot in Andaman
    Andaman photoshoot
    photoshoot at Andaman

    ReplyDelete
  22. Thanks for providing such nice information, bulk sms Coimbatore is very helpful and it is used to send a single information to thousands of people at a time, so we can reach people easily. It is one of the most effective, reliable and cost effective ways to market businesses. It allows you to get a higher income and provides a customer.

    bulk sms coimbatore | sms api | bulk sms provider in india | service explicit | sms gateway price india

    ReplyDelete
  23. I definitely enjoy every little bit of it and It is a great website. I want to thank you for the content. I learn a lot from your blog. Good job! You guys do a great blog and have some great content. Keep up the good work.
    best hr management software india

    ReplyDelete
  24. Really nice article. Thanks for sharing. Keep share much more. Good Luck.
    best hotels to stay in yercaud

    ReplyDelete
  25. Which is some inspirational stuff. Never knew that opinions might be this varied. Thank you for all the enthusiasm to provide such helpful information here.바카라사이트 It helped me a lot. If you have time, I hope you come to my site and share your opinions. Have a nice day.

    ReplyDelete
  26. Hi, I am John Smith I am Web Developer, It is an amazing blog thanks for the sharing the blog. Frantic infotech provide the ios e-commerce app development such as an information about software development for costumer service. Frantic infotech also provide the ios education app development . Theve delopment of advanced web applications is Orient Software’s specialty and we will successfully fulfill all your web application development requirements, from small-sized to wider-ranged projects. We Also do work multiple platforms like:
    Flutter app development
    android app development
    react native app development
    Hardware Mobile App Development
    penetration testing
    angularjs web development

    ReplyDelete

Post a Comment

Popular posts from this blog

Change Port on a Spring Boot Application when using intelliJ

How to set up a SQL Server 2008 Local Database

Add Guava Cache to Spring Boot to Cache Method Calls