Back to Intellij Community

JoinDeclarationAndAssignment

plugins/kotlin/code-insight/descriptions/resources-en/inspectionDescriptions/JoinDeclarationAndAssignment.html

2025.3-rc-2666 B
Original Source

Reports property declarations that can be joined with the following assignment.

Example:

val x: String
  x = System.getProperty("")

The quick fix joins the declaration with the assignment:

val x = System.getProperty("")

Configure the inspection:

You can disable the option Report with complex initialization of member properties to skip properties with complex initialization. This covers two cases:

  1. The property initializer is complex (it is a multiline or a compound/control-flow expression)
  2. The property is first initialized and then immediately used in subsequent code (for example, to call additional initialization methods)