How do I suppress "Contents of collection are queried but never updated"

Is there a way to suppress this warning?

I have collections that I query multiple times in a method but never actually update, so while this warning is technically correct, it feels annoying to see yellow in my code for something I am doing intentionally.

thx
andy

5 comments

Andy Kriger wrote:

Is there a way to suppress this warning?

I have collections that I query multiple times in a method but never actually update, so while this warning is technically correct, it feels annoying to see yellow in my code for something I am doing intentionally.


That sounds like the inspection is incorrectly triggering. It should
detect that you are initializing the collections in some way but never
updating them. Unless you are intentionally querying empty uninitialized
collections, in which case, just disable the inspection or live with the
yellow ;)

Ciao,
Gordon

--
Gordon Tyler (Software Developer)
Quest Software <http://www.quest.com/>
260 King Street East, Toronto, Ontario M5A 4L5, Canada
Voice: (416) 933-5046 | Fax: (416) 933-5001

0


Is it actually that your queries are pointless, or is there an update of the collection that is being missed? If the inspection is actually correct, you can suppress it just like any other inspection, with a @SupressWarnings annotation or a //noinspection comment. The quickfix should supply either one, if you want.

--Dave Griffith

0

I have class A that extends HashMap. In a method in class B, I create an instance of A (which initialized A with info in A.init) and get values from A. So I'm not updating A in B, but I don't need to so I don't want to see the inspector warning.

@SuppressWarnings("all") doesn't seem to have any affect on the code.

0

Hello,
do you use @SuppressWarnings("ALL") or as you mentioned @SuppressWarnings("all")? In first case, could you please give me a code fragment where it is not work.
Thank you.

0
@SuppressWarnings("MismatchedQueryAndUpdateOfCollection")
1

Please sign in to leave a comment.