Constructor parameter is never used as a property
Reports primary constructor parameters that can have val
or var
removed.
Class properties declared in the constructor increase memory consumption. If the parameter value is only used in the constructor, you can omit them.
Note that the referenced object might be garbage-collected earlier.
Example:
class Task(val name: String) {
init {
print("Task created: $name")
}
}
The quick-fix removes the extra val
or var
keyword:
class Task(name: String) {
init {
print("Task created: $name")
}
}
Inspection Details | |
---|---|
Available in: | IntelliJ IDEA 2023.3, Qodana for JVM 2023.3 |
Plugin: | Kotlin, @snapshot@ |
Last modified: 13 July 2023