Inspectopedia 2026.2 Help

Duplicate arguments in 'setOf' and 'mapOf' functions

Reports duplicate constant elements in set factory functions and duplicate constant keys in map factory functions.

Duplicate entries in collection factory functions are often unintended and may indicate a bug or typo. In set factory functions, duplicate elements are ignored because sets can contain only unique elements. In map factory functions, entries with the same key overwrite earlier entries, and only the last value associated with the key is retained.

The inspection applies to the following map factory functions:

  • mapOf()

  • mutableMapOf()

  • hashMapOf()

  • linkedMapOf()

  • sortedMapOf()

Duplicate map keys are detected for entries created using the to operator.

The inspection applies to the following set factory functions:

  • setOf()

  • mutableSetOf()

  • hashSetOf()

  • linkedSetOf()

  • sortedSetOf()

The inspection reports arguments whose values can be evaluated as compile-time constants, including constant literals and references.

const val

Examples:

val numbers = setOf(1, 1, 2)

The value 1 appears multiple times.

val mapping = mapOf( 1 to "first", 1 to "second", )

Both entries use the same key.

Example with const val:

const val ID = 42 val ids = setOf(ID, 42)

Both arguments evaluate to the same constant value.

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.

DuplicateArgumentsInSetOfAndMapOfFunctions
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: DuplicateArgumentsInSetOfAndMapOfFunctions

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 DuplicateArgumentsInSetOfAndMapOfFunctions

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.2, Qodana for JVM 2026.2,

Last modified: 30 June 2026