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
Dart

Dart static code analysis

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

  • All rules 126
  • Vulnerability4
  • Bug15
  • Security Hotspot8
  • Code Smell99
Filtered: 5 rules found
performance
    Impact
      Clean code attribute
        1. Literal constructors parameters of @immutable classes should be const

           Code Smell
        2. @immutable classes should only have const constructors

           Code Smell
        3. Unnecessary use of "toList" with spread operator

           Code Smell
        4. For elements should be preferred to Map.fromIterable

           Code Smell
        5. "static final" declarations should be "const" instead

           Code Smell

        "static final" declarations should be "const" instead

        intentionality - efficient
        maintainability
        Code Smell
        • performance

        Why is this an issue?

        More Info

        The value of a finalor const variable can’t be changed. In Dart const declares a compile-time constant, which will be computed during compilation and this might improve performance. So in general it is recommended to use const, where possible. In Dart it is also possible to use const to create constant values, as well as to declare constructors that create constant values. final declarations initialized with such values should be const.

        Noncompliant code example

        final i = 1000; // Noncompliant
        final ints = const [1, 2, 3]; // Noncompliant
        
        class MyClass {
          static final name = "NAME"; // Noncompliant
        }
        

        Compliant solution

        const i = 1000;
        const ints = [1, 2, 3]; // const after assignment can be omitted
        
        class MyClass {
          static const name = "NAME";
        }
        
          Available In:
        • SonarQube CloudDetect issues in your GitHub, Azure DevOps Services, Bitbucket Cloud, GitLab repositories
        • SonarQube ServerAnalyze code in your
          on-premise CI
          Developer Edition
          Available Since
          10.7

        © 2008-2025 SonarSource SA. All rights reserved.

        Privacy Policy | Cookie Policy | Terms of Use