SonarQube: bug with lateinit in Kotlin

Hello all!
We are using SonarQube in our project and have decided to eliminate all the errors it reports. However, we’ve run into a dilemma because there are critical bugs related to the lateinit construct. SonarQube is reporting an error on all lateinit variables, saying, “class.getValue() may return null, but is declared Nonnull.”

So, we have a question: is there a way to modify the code to avoid this error on lateinit variables, or is it expected that this error will always occur on all lateinit variables (in which case, we’re curious about how to disable SonarQube specifically for lateinit variables)?

Hey there.

  • What version of SonarQube are you using?
  • Can you offer a code sample where an issue is being raised where you think it shouldn’t?