Inspectopedia 2026.3 Help

Suspicious getter: it returns a new mutable object on each access

Reports property getters that return a new mutable object on each access.

A property that holds a mutable object normally keeps one object. Every caller then reads and changes that same object.

A getter breaks this. It runs again on each access and returns a new object, so a caller changes an object that no other caller reads.

The inspection covers the coroutine objects Job, SupervisorJob, CompletableDeferred, CoroutineScope, MainScope, MutableStateFlow, MutableSharedFlow, Channel, Mutex and Semaphore.

It also covers a mutable collection factory such as mutableListOf or mutableMapOf.

Example:

class Service { val job get() = Job() val items get() = mutableListOf<String>() fun add(value: String) { items.add(value) // lost: this writes to a new list } fun stop() { job.cancel() // no effect: this cancels a new job } }

To share one object, declare the property with an initializer:

class Service { val job = Job() val items = mutableListOf<String>() fun add(value: String) { items.add(value) } fun stop() { job.cancel() } }

If you want a factory, use a function instead. A name such as newJob() shows the intent to the caller.

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.

SuspiciousGetterForMutableObject
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 | Kotlin | Probable bugs

Inspection ID: SuspiciousGetterForMutableObject

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 SuspiciousGetterForMutableObject

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 2026.3, Qodana for JVM 2026.3,

Last modified: 20 November 2026