kotlin:S6518 Wrong warning in SonarLint for IntelliJ


  • Java: JetBrains s.r.o. 17.0.10
  • OS: Linux amd64
  • IDE: IntelliJ IDEA 2024.1
  • SonarLint:

The following code gives the wrong S6518 warning Replace function call with indexed accessor.:

yaml.yamlMap.get<YamlMap>("info")?.getScalar("title")?.content ?: error("info.title not specified")

Or is there a way to provide a type with yaml.yamlMap["info"] in kotlin?

I’m using the com. charleskorn. kaml package.

Hello @MartinX3, and welcome to the Sonar Community.

Thank you for pointing out this false positive; there is room for improving the rule! You can track the progress on its resolution at [SONARKT-386] - Jira.


Thank you!

I made an account there but I have no clue where to enable the notifications for this bug entry.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.