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
 
Tags
    Impact
      Clean code attribute
        1. "mounted" should be checked before using a "BuildContext " after an async operation

           Bug
        2. "void" variables should not be assigned a value

           Bug
        3. Constant patterns should not be used with type literals

           Bug
        4. "is!" should be used instead of "!is"

           Bug
        5. Getters should not be recursive

           Bug
        6. Nullable type parameter values should not be null checked with `!`

           Bug
        7. Regular expressions should be syntactically valid

           Bug
        8. Color definitions should be valid

           Bug
        9. "const" modifier should not be redundant

           Bug
        10. Setters should not declare return types

           Bug
        11. Inappropriate collection calls should not be made

           Bug
        12. Unnecessary equality checks should not be made

           Bug
        13. The original exception object should be rethrown

           Bug
        14. "==" operator and "hashCode()" should be overridden in pairs

           Bug
        15. Jump statements should not occur in "finally" blocks

           Bug

        "const" modifier should not be redundant

        intentionality - clear
        reliability
        Bug
        • redundant

        Why is this an issue?

        More Info

        In Dart, const is used to declare compile-time constants. It can also be used to declare constant values, typically provided by constant constructors. This constructor, if used within const context will create an instance as a compile-time constant. This is an example of usage of a constant constructor:

        Declaration

        class Person {
          final int age;
          final String name;
        
          const Person(this.age, this.name);
        }
        

        Usage

        void f() {
          var p = const Person(40, 'A');
          var family = const [Person(40, 'A'), Person(39, 'B')];
        }
        

        When you’re already inside the const context, there’s no need to repeat the keyword. So instead of writing const [const Person(40, 'A'), const Person(39, 'B')] you can just write const [Person(40, 'A'), Person(39, 'B')].

        This rule raises an issue when const modifier was used within another const context

        Noncompliant code example

        void f() {
          var family = const [const Person(40, 'A'), const Person(39, 'B')];
        }
        

        Compliant solution

        void f() {
          var family = const [Person(40, 'A'), Person(39, 'B')];
        }
        
          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