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

        Setters should not declare return types

        intentionality - clear
        reliability
        Bug

          Why is this an issue?

          More Info

          In Dart, a setter is a special type of function that is used to set the value of a property on an object. Setters are defined using the set keyword followed by the name of the property that the setter is associated with.

          To set the property, we simply assign a value to it as if it were a regular property. The setter function is automatically called with the value that we assign to the property.

          Functions declared with the set keyword can’t return any value, so setting any return type other than void is a compile-time error. While this is possible to still add void return type it is redundant and should be omitted.

          class Person {
            String name;
            int birthYear;
          
            Person(this.name, this.birthYear);
          
            // Adding a calculated property age
            int get age => currentYear - birthYear;
            void set age(int value) => birthYear = currentYear - value; // Noncompliant
          }
          
          class Person {
            String name;
            int birthYear;
          
            Person(this.name, this.birthYear);
          
            // Adding a calculated property age
            int get age => currentYear - birthYear;
            set age(int value) => birthYear = currentYear - value;
          }
          
            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