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. Parameter names should match base declaration

           Code Smell
        2. Allowing unrestricted navigation in WebViews is security-sensitive

           Security Hotspot
        3. Processing persistent unique identifiers is security-sensitive

           Security Hotspot
        4. Exposing native code through JavaScript interfaces is security-sensitive

           Security Hotspot
        5. "child" properties should be placed last in widget instantiation

           Code Smell
        6. Literal constructors parameters of @immutable classes should be const

           Code Smell
        7. Unnecessary widget containers should be removed

           Code Smell
        8. Widget constructors should have a key parameter

           Code Smell
        9. "SizedBox" should be used to add a whitespace to a layout

           Code Smell
        10. "mounted" should be checked before using a "BuildContext " after an async operation

           Bug
        11. Flutter widget "createState" should only return a new "State"

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

           Code Smell
        13. Const constructors should be invoked with const

           Code Smell
        14. "part of" directives should be used with strings

           Code Smell
        15. Unnecessary getters and setters should be removed

           Code Smell
        16. Web-only libraries should only be used in Flutter web plugins

           Code Smell
        17. "void" variables should not be assigned a value

           Bug
        18. Super parameters should be preferred to forwarding parameters to super

           Code Smell
        19. If-null operator shouldn't be used with "null"

           Code Smell
        20. Generic function type syntax should be preferred for parameters

           Code Smell
        21. Unnecessary nullable in final declaration should be removed

           Code Smell
        22. Null-aware assignments should make sense

           Code Smell
        23. "new" keyword shouldn't be used

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

           Code Smell
        25. Unnecessary string interpolations

           Code Smell
        26. "late" modifier should be necessary

           Code Smell
        27. Unnamed constructor should be used instead of `.new`

           Code Smell
        28. Initialization formals shouldn't be unnecessarily type annotated

           Code Smell
        29. Unnecessary braces in string interpolation should be removed

           Code Smell
        30. Constant patterns should not be used with type literals

           Bug
        31. Triple slash should be used for documentation comments

           Code Smell
        32. Initializing formals should be used

           Code Smell
        33. Spread collections should be preferred to chaining list insertions

           Code Smell
        34. Inline list literals should be preferred to chains of insertions

           Code Smell
        35. Pubspec urls should be secure

           Vulnerability
        36. Referenced packages should be listed as dependencies

           Code Smell
        37. Dependencies should be sorted

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

           Code Smell
        39. Adjacent string concatenation should be preferred

           Code Smell
        40. Fields should not be overridden

           Code Smell
        41. Non-constant names should comply with a naming convention

           Code Smell
        42. Library prefixes shouldn't start with underscore

           Code Smell
        43. Private types shouldn't be exposed in public API

           Code Smell
        44. Library prefixes should comply with naming conventions

           Code Smell
        45. Library annotations should be attached to library directive

           Code Smell
        46. Library doc comments should be attached to library directive

           Code Smell
        47. Implementation imports shouldn't be used

           Code Smell
        48. Implicit tearoff of "call" shouldn't be used

           Code Smell
        49. Single cascade shouldn't be used

           Code Smell
        50. Function literals shouldn't be used in foreach calls

           Code Smell
        51. Wildcard variable shouldn't be used

           Code Smell
        52. "is!" should be used instead of "!is"

           Bug
        53. Relative lib imports should not be used

           Code Smell
        54. Uninitialized variables and fields should be explicitly typed

           Code Smell
        55. Types should not be used as parameter names

           Code Smell
        56. Void functions should not return null

           Code Smell
        57. Getters should not be recursive

           Bug
        58. Function declarations should be preferred over variables

           Code Smell
        59. Nullable type parameter values should not be null checked with `!`

           Bug
        60. Extension identifiers should comply with a naming convention

           Code Smell
        61. Local identifiers should not start with underscore

           Code Smell
        62. Null checks in equality operators should be avoided

           Code Smell
        63. If-null operator should be preferred

           Code Smell
        64. Null-aware operators should be preferred

           Code Smell
        65. Unnecessary character escapes should be removed

           Code Smell
        66. Redundant type casts should be removed

           Code Smell
        67. Enabling JavaScript support for WebViews is security-sensitive

           Security Hotspot
        68. Empty constructor bodies should be replaced with a semicolon

           Code Smell
        69. Regular expressions should be syntactically valid

           Bug
        70. Cipher algorithms should be robust

           Vulnerability
        71. Encryption algorithms should be used with secure mode and padding scheme

           Vulnerability
        72. Generic function type aliases should be preferred

           Code Smell
        73. Using clear-text protocols is security-sensitive

           Security Hotspot
        74. Accessing Android external storage is security-sensitive

           Security Hotspot
        75. Type parameters should not shadow other type parameters

           Code Smell
        76. Server certificates should be verified during SSL/TLS connections

           Vulnerability
        77. Using weak hashing algorithms is security-sensitive

           Security Hotspot
        78. Color definitions should be valid

           Bug
        79. "await" should only be used with futures

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

           Code Smell
        81. Cognitive Complexity of functions should not be too high

           Code Smell
        82. "const" modifier should not be redundant

           Bug
        83. "switch" statements should cover all cases

           Code Smell
        84. Interpolation should be used instead of String concatenation

           Code Smell
        85. Ternary operators should not be nested

           Code Smell
        86. Collection literals should be preferred

           Code Smell
        87. Conditional assignment should be preferred

           Code Smell
        88. Iterable "whereType" should be used to filter by type

           Code Smell
        89. "this" should only be used when required

           Code Smell
        90. Fields that are only assigned in the constructor should be "readonly"

           Code Smell
        91. Exceptions should not be ignored

           Code Smell
        92. Variables should not be initialized with "null"

           Code Smell
        93. Setters should not declare return types

           Bug
        94. "is!" should be used instead of "!(. is .)"

           Code Smell
        95. Dart build, compiler, or analyzer configuration errors

           Code Smell
        96. Using pseudorandom number generators (PRNGs) is security-sensitive

           Security Hotspot
        97. Inappropriate collection calls should not be made

           Bug
        98. Unnecessary equality checks should not be made

           Bug
        99. Code annotated as deprecated should not be used

           Code Smell
        100. Unused assignments should be removed

           Code Smell
        101. The original exception object should be rethrown

           Bug
        102. File names should comply with a naming convention

           Code Smell
        103. Cyclomatic Complexity of functions should not be too high

           Code Smell
        104. Unused local variables should be removed

           Code Smell
        105. Control structures should use curly braces

           Code Smell
        106. "==" operator and "hashCode()" should be overridden in pairs

           Bug
        107. Package names should comply with a naming convention

           Code Smell
        108. String literals should not be duplicated

           Code Smell
        109. Overriding methods should do more than simply call the same method in the super class

           Code Smell
        110. "@override" should be used on overriding members

           Code Smell
        111. "isEmpty" or "isNotEmpty" should be used to test for emptiness

           Code Smell
        112. Constant names should comply with a naming convention

           Code Smell
        113. Jump statements should not occur in "finally" blocks

           Bug
        114. Track uses of "TODO" tags

           Code Smell
        115. Track uses of "FIXME" tags

           Code Smell
        116. Deprecated code should be removed

           Code Smell
        117. Files should end with a newline

           Code Smell
        118. Unnecessary imports should be removed

           Code Smell
        119. Deprecated elements should include explanation

           Code Smell
        120. Utility classes should not have public constructors

           Code Smell
        121. Empty statements should be removed

           Code Smell
        122. Functions should not have too many parameters

           Code Smell
        123. Unused "private" fields should be removed

           Code Smell
        124. Unused labels should be removed

           Code Smell
        125. Standard outputs should not be used directly to log anything

           Code Smell
        126. Class names should comply with a naming convention

           Code Smell

        Implementation imports shouldn't be used

        consistency - conventional
        maintainability
        Code Smell

          Why is this an issue?

          How can I fix it?

          More Info

          In Dart, there’s a convention to distinguish between public API and the implementation details. It states:

          • Files inside lib/src are considered internal implementation detail, and shouldn’t be referenced
          • Other files inside the lib directory are publicly accessible and are safe to be imported

          Introducing the dependency on the internal implementation of other packages is not recommended as it is the subject to change and may introduce maintainability issues and break your code unexpectedly.

          Exceptions

          It is still safe to reference libraries from lib/src within the same package.

            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