Mismatched query and update of collection
Reports collections whose contents are either queried and not updated, or updated and not queried.
Such inconsistent queries and updates are pointless and may indicate either dead code or a typo.
Use the inspection settings to specify name patterns that correspond to update/query methods. Query methods that return an element are automatically detected, and only those that write data to an output parameter (for example, an
OutputStream) need to be specified.
Suppose you have your custom
FixedStack class with method
You can add
store to the update methods table in order to report mismatched queries like:
Query names start with
[contains, copyInto, equals, forEach, get, hashCode, indexOf, iterator, lastIndexOf, parallelStream, peek, propertyNames, save, size, store, stream, toArray, toString, write]
Update names start with
[add, clear, insert, load, merge, offer, poll, pop, push, put, remove, replace, retain, set, sort, take]
Ignored classes (including subclasses)
IntelliJ IDEA 2023.3, Qodana for JVM 2023.3