Skip to content

[Kotlin] Bogus errors NP_NONNULL_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR #1036

@rupert-jung-mw

Description

@rupert-jung-mw

Issue Description

When analyzing Kotlin dataclasses, I get one "critical" error for each non-nullable constructor parameter without a default value with the following description:

"The field is marked as non-null, but isn't written to by the constructor. The field might be initialized elsewhere during constructor, or might always be initialized before use."

This is just plain wrong as the property someValue is literally part of the constructor and has to be set there with a non-null value.

Environment

Sonar Qube 9.9 (build 65466)

Component Version
SonarQube 65466
Sonar-FindBugs 4.2.4
Maven 3.9
Kotlin 2.0.20
data class MyClass(var someValue: String);

Thank you!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions