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
imports
    Impact
      Clean code attribute
        1. Package imports should be consistent and avoid redundancy

           Code Smell

        Package imports should be consistent and avoid redundancy

        consistency - conventional
        maintainability
        Code Smell
        • convention
        • imports

        This is an issue when the same Go package is imported multiple times (both directly and with an alias) or when code uses the full package name instead of a defined alias.

        Why is this an issue?

        How can I fix it?

        More Info

        Importing the same package multiple times creates redundancy and confusion about which import to use. When a package is imported both with and without an alias, it’s unclear which approach developers should follow throughout the codebase.

        Inconsistent usage of import aliases further compounds this problem. If an alias is defined for a package, using the full package name in some places and the alias in others makes the code harder to read and maintain.

        This inconsistency can lead to:

        • Confusion about which import style to use
        • Potential naming conflicts if the same package is referenced differently
        • Reduced code readability and maintainability
        • Unnecessary cognitive load when reading the code

        Go’s import system is designed to be explicit and clear. Following consistent import patterns helps maintain this clarity.

        What is the potential impact?

        This issue primarily affects code maintainability and readability. While not a security concern, inconsistent imports can lead to developer confusion, increased cognitive load when reading code, and potential maintenance issues when refactoring or updating dependencies.

          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