False Positive - Go - Rule godre:S8193 - Variables in if short statements

  • What language is this for? Go

  • Which rule? godre:S8193 - Variables in if short statements should be used beyond just the condition

  • Why do you believe it’s a false-positive?

    In Go it is idiomatic to use the following style for error handling whether the err variable is used in the body of the if statement or not.

    if err := someCall(); err != nil {
    ...
    }

    You find this coding style everywhere in articles and blogs on Go error handling.

    Can this rule ignore situations where the variable is called ‘err’ or some recognisable variant? Maybe have a parameter for the rule that can list variable names that are allowed and do not raise issues?

  • We are using SonarQube Server, Data Center Edition v2026.1.2 (121356)

  • How can we reproduce the problem?

    Any Go code with the code snippet like this where err is not used inside the if statement should reproduce the issue:

    if err := someCall(); err != nil {
    ...
    }