Inspectopedia Help

Write-only object

Reports objects that are modified but never queried.

The inspection relies on the method mutation contract, which could be inferred or pre-annotated for some library methods. This inspection does not report collections, maps, and string builders, as these types are reported by other more precise inspections.

Example:

AtomicReference<String> ref = new AtomicReference<>(); ref.set("hello"); // ref is never used again

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.

WriteOnlyObject
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

Use the Ignore impure constructors option to control whether to process objects created by constructor or method whose purity is not known. Unchecking the option may introduce some false-positives if the object reference is intentionally leaked during the construction.

New in 2021.2

Inspection options

Here you can find the description of settings available for the Write-only object inspection, and the reference of their default values.

Ignore impure constructors

Default: Selected

Availability

By default bundled with

IntelliJ IDEA 2024.1, Qodana for JVM 2024.1,

Can be installed with plugin

Java, 241.18072

Last modified: 18 June 2024