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: 2 rules found
redundant
    Impact
      Clean code attribute
        1. "const" modifier should not be redundant

           Bug
        2. Overriding methods should do more than simply call the same method in the super class

           Code Smell

        "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

        © 2025 SonarSource Sàrl. All rights reserved.

        Privacy Policy | Cookie Policy | Terms of Use