SonarSource Rules
  • Products

    In-IDE

    Code Quality and Security in your IDE with SonarQube Ide

    IDE extension that lets you fix coding issues before they exist!

    Discover SonarQube for IDE

    SaaS

    Code Quality and Security in the cloud with SonarQube Cloud

    Setup is effortless and analysis is automatic for most languages

    Discover SonarQube Cloud

    Self-Hosted

    Code Quality and Security Self-Hosted with SonarQube Server

    Fast, accurate analysis; enterprise scalability

    Discover SonarQube Server
  • SecretsSecrets
  • ABAPABAP
  • AnsibleAnsible
  • ApexApex
  • AzureResourceManagerAzureResourceManager
  • CC
  • C#C#
  • C++C++
  • CloudFormationCloudFormation
  • COBOLCOBOL
  • CSSCSS
  • DartDart
  • DockerDocker
  • FlexFlex
  • GitHub ActionsGitHub Actions
  • GoGo
  • HTMLHTML
  • JavaJava
  • JavaScriptJavaScript
  • JSONJSON
  • JCLJCL
  • KotlinKotlin
  • KubernetesKubernetes
  • Objective CObjective C
  • PHPPHP
  • PL/IPL/I
  • PL/SQLPL/SQL
  • PythonPython
  • RPGRPG
  • RubyRuby
  • RustRust
  • ScalaScala
  • ShellShell
  • SwiftSwift
  • TerraformTerraform
  • TextText
  • TypeScriptTypeScript
  • T-SQLT-SQL
  • VB.NETVB.NET
  • VB6VB6
  • XMLXML
  • YAMLYAML
Go

Go static code analysis

Unique rules to find Bugs, Vulnerabilities, Security Hotspots, and Code Smells in your GO code

  • All rules 94
  • Vulnerability21
  • Bug13
  • Security Hotspot14
  • Code Smell46
Filtered: 1 rule found
dead-code
    Impact
      Clean code attribute
        1. Variables should be used

           Code Smell

        Variables should be used

        intentionality - clear
        maintainability
        Code Smell
        • unused
        • dead-code

        This rule raises an issue when variables are declared but never used, assigned but never read, or when pointer variables are never dereferenced.

        Why is this an issue?

        How can I fix it?

        More Info

        Unused variables and ineffectual assignments create dead code that serves no purpose in program execution. This dead code:

        • Reduces code readability by cluttering the codebase with unnecessary declarations
        • Can confuse other developers who might assume the variable serves a purpose
        • May indicate incomplete implementations or leftover code from refactoring
        • Increases maintenance burden without providing any value
        • Can mask real issues where a variable was intended to be used but was forgotten

        In Go, the compiler will catch completely unused variables, but it won’t detect cases where variables are assigned but never read, or where pointer variables are never dereferenced. These patterns often indicate logic errors or incomplete code that should be addressed.

        What is the potential impact?

        While unused variables don’t directly impact runtime performance or security, they reduce code quality and maintainability. Dead code can hide bugs, make code reviews more difficult, and create confusion for developers working on the codebase.

          Available In:
        • SonarQube CloudDetect issues in your GitHub, Azure DevOps Services, Bitbucket Cloud, GitLab repositories

        © 2025 SonarSource Sàrl. All rights reserved.

        Privacy Policy | Cookie Policy | Terms of Use