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
documentation
    Impact
      Clean code attribute
        1. Blank imports should be documented to explain their purpose

           Code Smell

        Blank imports should be documented to explain their purpose

        intentionality - clear
        maintainability
        Code Smell
        • documentation

        This rule raises an issue when a blank import (using import _ "package") is not accompanied by a comment explaining its purpose.

        Why is this an issue?

        How can I fix it?

        More Info

        Blank imports in Go are used to import packages purely for their side effects, such as package initialization or registration of handlers. While sometimes necessary, they make dependencies less explicit and can lead to confusion about why a package is being imported.

        When a blank import appears without documentation, it creates several problems:

        • Reduced code clarity: Other developers cannot easily understand why the package is imported
        • Maintenance difficulties: It becomes harder to determine if the import is still needed during refactoring
        • Unexpected behavior: The side effects of the imported package may not be obvious, leading to surprising runtime behavior

        Blank imports are commonly used for legitimate purposes like registering image decoders, database drivers, or plugins. However, without proper documentation, these imports become a source of confusion rather than clarity.

        What is the potential impact?

        Undocumented blank imports reduce code maintainability and can lead to confusion during development and maintenance. While not a security issue, they make the codebase harder to understand and modify safely.

          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