Swift False Positive for S1481 and S1172

Code blocks like these:

let page = page(at: index)
guard let page else {
    return nil
}
page.doSomething()

Trigger issues from S1481 after the update to SonarQube Server 2026.1.0.119033.

The variable is clearly used, but I think the new-ish swift syntax for the short hand guard with guard let varName else instead of guard let newVarName = varName else trips the analysis since the update.

I see the same issues with rule S1172 where it says a parameter is unused if the first occurrence is of type guard let parameter else {

I had a look at the release logs, and found SONAR-27277 scheduled for the next update, however this JIRA does not have any details.. Could you confirm if this would fix the issues?

Thanks!

1 Like

yeah, noticed this in 2026.2 as well. Definitely appears to be triggering incorrectly

Hello,

@Nef10 The fix for the FP in case of

was deployed to SonarQube Cloud quite some time ago,
and also made into SonarQube Server 2026.2,
and then was also backported to SonarQube Server 2026.1.2 LTA,
ie both versions do not raise an issue on the above code snipped.

@munkyxtc if with SonarQube Sever 2026.2 you still see similar issues, then please provide exact code snippet(s) to reproduce it, because the above one reproduces the issue only with SonarQube Server 2026.1

Thanks, after updating the server to >= 2026.1.2 this is fixed for me.

1 Like