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: 3 rules found
style
    Impact
      Clean code attribute
        1. Consecutive function parameters with the same type should be grouped

           Code Smell
        2. Semicolons should not be used unnecessarily

           Code Smell
        3. Import statements should be factored into a single block

           Code Smell

        Import statements should be factored into a single block

        consistency - conventional
        maintainability
        Code Smell
        • convention
        • style

        This rule raises an issue when there are multiple separate import statements that could be grouped together in a factored import block.

        Why is this an issue?

        How can I fix it?

        More Info

        Go supports two ways to write import statements: multiple separate statements or a single factored statement that groups imports in parentheses.

        While both approaches are syntactically valid, the Go community strongly recommends using factored import statements. This convention is documented in the official Go Tour and is widely adopted across Go codebases.

        Factored imports offer several advantages:

        • Better organization: All imports are grouped in one place, making dependencies easier to see at a glance
        • Cleaner code: Reduces visual clutter by eliminating repeated import keywords
        • Consistency: Follows the established Go style guidelines that most developers expect
        • Tool compatibility: Many Go formatting tools like gofmt automatically convert separate imports to factored form

        Using separate import statements makes code look less polished and can signal unfamiliarity with Go conventions to other developers.

        What is the potential impact?

        This is a style issue that affects code readability and consistency. While it doesn’t impact functionality, following Go conventions makes code more maintainable and professional.

          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