Inspectopedia 2025.2 Help

Mismatched query and update of collection

Reports collections whose contents are either queried and not updated, or updated and not queried.

Locating this inspection

By ID

Can be used to locate inspection in e.g. Qodana configuration files, where you can quickly enable or disable it, or adjust its settings.

MismatchedQueryAndUpdateOfCollection
Via Settings dialog

Path to the inspection settings via IntelliJ Platform IDE Settings dialog, when you need to adjust inspection settings directly from your IDE.

Settings or Preferences | Editor | Inspections | Java | Probable bugs

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.

Example:

Suppose you have your custom FixedStack class with method store():

public class FixedStack<T> extends Collection<T> { public T store(T t) { // implementation } }

You can add store to the update methods table in order to report mismatched queries like:

void test(int i) { FixedStack<Integer> stack = new FixedStack<>(); stack.store(i); }

Inspection options

Here you can find the description of settings available for the Mismatched query and update of collection inspection, and the reference of their default values.

Ignored classes (including subclasses)

Default value:

Empty

Suppressing Inspection

You can suppress this inspection by placing the following comment marker before the code fragment where you no longer want messages from this inspection to appear:

//noinspection MismatchedQueryAndUpdateOfCollection

More detailed instructions as well as other ways and options that you have can be found in the product documentation:

Inspection Details

By default bundled with:

IntelliJ IDEA 2025.2, Qodana for JVM 2025.2,

Last modified: 18 September 2025