What language is this for? Kotlin ( java interop )
Which rule? kotlin:S6518
SonarQube Server / Community Build - Developer Edition v2025.6.1 (117629)
How can we reproduce the problem? Give us a self-contained snippet of code
Given the following Java class definition
package sandbox;
public class UserId {
private final String value;
public UserId(String value) {
this.value = value;
}
public String get() {
return value;
}
}
and the following kotlin code
package sandbox
data class User(val id: UserId, val name: String)
interface UserRepository {
fun findById(id: String): User?
fun save(user: User): User?
}
class UserService(val repository: UserRepository) {
fun updateUserName(userId: UserId, newName: String) {
// The call to .get() below wrongly triggers kotlin:S6518
repository.findById(userId.get())?.let { // <====== HERE
repository.save(it.copy(name = newName))
} ?: throw IllegalStateException(
"User with id $userId not found",
)
}
}
the rule should not be triggered yet it is triggered both in sonar and in sonar lint in Intellij
Thanks for the report and the reproducer. I was able to confirm this issue under certain conditions. The good news is that we are already working on a fix for this issue and will release a fix within the near future.
Any news on a fix for this issue ? It’s been a while now and forced us to downgrade the rule to info while waiting for a fix.
A quick search in the community forum lists at least 5 different report for incorrect set or get calls being flagged ( I encounted both ) and that’s only for people who bothered reporting the rule.
I kind of expected a fix to address all issues that had been reported and was disapointed to see we still had alerts on jooq code as described in kotlin:S6518 False Positive using JOOQ
Indeed, we did some improvements to the rule back in May, and I can’t reproduce the problem on the exact code snippet from the thread you linked. The rule S6518 currently flags set(...) calls only if there is no subsequent dot-qualified call, i.e. the result of the set function is unused. And in this case, the rule will only flag the last call in the chain.
Could you provide a specific reproducer for jooq that you encounter in your code (and, for that matter, any unresolved reproducers for this rule that you still have)?
I was still encountering s6518 false positives on jooq code in yesterday’s anlysis on 2026.3 I upgraded our sonar install to 2026.4 yesterday and now that the nightly run has passed we don’t have any violations anymore so I guess the may improvements have been release in 2026.4
When I search for s6518 in the sonar release notes for 2026.3 or 2026.4 I don’t have any hit this makes it difficult to know when fixes have landed