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
  • GroovyGroovy
  • 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
Kotlin

Kotlin static code analysis

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

  • All rules 175
  • Vulnerability42
  • Bug27
  • Security Hotspot20
  • Code Smell86
 
Tags
    Impact
      Clean code attribute
        1. Core plugins IDs should be replaced by their shortcuts

           Code Smell
        2. Gradle settings file should always be present

           Code Smell
        3. Dependencies should be grouped by destination

           Code Smell
        4. Tasks should define "description" and "group"

           Code Smell
        5. "rootProject.name" should always be present in Gradle settings

           Code Smell
        6. Dependency versions shouldn't be hard-coded

           Code Smell
        7. "tasks.register()" should be preferred over "tasks.create()"

           Code Smell
        8. Null checks should be useful

           Code Smell
        9. Variables assigned values should be read

           Code Smell
        10. "It" shouldn't be used as a lambda parameter name

           Code Smell
        11. Check for preconditions should be simplified

           Code Smell
        12. Redundant type casts should be removed

           Code Smell
        13. Type casts and type checks that can never succeed should be removed

           Code Smell
        14. Expression should be simplified with "isEmpty", "isNotEmpty" or "isNullOrEmpty"

           Code Smell
        15. "find" should be replaced with "any", "none" or "contains"

           Code Smell
        16. Function chain using "filter" should be simplified

           Code Smell
        17. Abstract class should be interface

           Code Smell
        18. Collection should be immutable if contents is not changed

           Code Smell
        19. Structural equality tests should use "==" or "!="

           Code Smell
        20. Element access should use indexed access operators

           Code Smell
        21. Single function interfaces should be functional interfaces

           Code Smell
        22. Functional interface implementations should use lambda expressions

           Code Smell
        23. Singleton pattern should use object declarations or expressions

           Code Smell
        24. Delegator pattern should use "by" clause

           Code Smell
        25. Getter and setter pattern should use property getters and setters

           Code Smell
        26. "when" statements should be used instead of chained "if" statements

           Code Smell
        27. "return" statements should be lifted before "if" or "when" statement

           Code Smell
        28. "Unit" should be used instead of "Void"

           Code Smell
        29. "suspend" modifier should not be redundant

           Code Smell
        30. Kotlin coroutines API for timeouts should be used

           Code Smell
        31. The return value of functions returning "Deferred" should be used

           Code Smell
        32. ViewModel classes should create coroutines

           Code Smell
        33. Extension functions on CoroutineScopes should not be declared as "suspend"

           Code Smell
        34. Suspending functions should not be called on a different dispatcher

           Code Smell
        35. Dispatchers should be injectable

           Code Smell
        36. Functions returning Flow/Channel should not be suspending

           Code Smell
        37. Suspending functions should be main-safe

           Code Smell
        38. Coroutine usage should adhere to structured concurrency principles

           Code Smell
        39. "MutableStateFlow" and "MutableSharedFlow" should not be exposed

           Code Smell
        40. Redundant methods should be avoided in data classes

           Code Smell
        41. Operator "is" should be used instead of "isInstance()"

           Code Smell
        42. Character classes in regular expressions should not contain the same character twice

           Code Smell
        43. Unicode-aware versions of character classes should be preferred

           Code Smell
        44. Character classes should be preferred over reluctant quantifiers in regular expressions

           Code Smell
        45. Empty lines should not be tested with regex MULTILINE flag

           Code Smell
        46. Regular expressions should not be too complicated

           Code Smell
        47. Lambdas should not have too many lines

           Code Smell
        48. Native features should be preferred to Guava

           Code Smell
        49. Multi-line comments should not be empty

           Code Smell
        50. Functions should not have identical implementations

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

           Code Smell
        52. "var" should be "val" if local variable is never re-assigned

           Code Smell
        53. Kotlin parser failure

           Code Smell
        54. Boolean checks should not be inverted

           Code Smell
        55. Code annotated as deprecated should not be used

           Code Smell
        56. Two branches in a conditional structure should not have exactly the same implementation

           Code Smell
        57. "when" statements should not be nested

           Code Smell
        58. Unused local variables should be removed

           Code Smell
        59. "when" statements should not have too many clauses

           Code Smell
        60. Track lack of copyright and license headers

           Code Smell
        61. Functions should not have too many lines of code

           Code Smell
        62. Control flow statements "if", "for", "while", "when" and "try" should not be nested too deeply

           Code Smell
        63. "if ... else if" constructs should end with "else" clauses

           Code Smell
        64. Sections of code should not be commented out

           Code Smell
        65. Statements should be on separate lines

           Code Smell
        66. String literals should not be duplicated

           Code Smell
        67. Functions should not be empty

           Code Smell
        68. Unused function parameters should be removed

           Code Smell
        69. Local variable and function parameter names should comply with a naming convention

           Code Smell
        70. "when" clauses should not have too many lines of code

           Code Smell
        71. Unused "private" methods should be removed

           Code Smell
        72. Track uses of "TODO" tags

           Code Smell
        73. Track uses of "FIXME" tags

           Code Smell
        74. Deprecated code should be removed

           Code Smell
        75. Unnecessary imports should be removed

           Code Smell
        76. Boolean literals should not be redundant

           Code Smell
        77. Redundant pairs of parentheses should be removed

           Code Smell
        78. Nested blocks of code should not be left empty

           Code Smell
        79. Functions should not have too many parameters

           Code Smell
        80. Expressions should not be too complex

           Code Smell
        81. Mergeable "if" statements should be combined

           Code Smell
        82. Tabulation characters should not be used

           Code Smell
        83. Files should not have too many lines of code

           Code Smell
        84. Lines should not be too long

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

           Code Smell
        86. Function names should comply with a naming convention

           Code Smell

        Statements should be on separate lines

        consistency - formatted
        maintainability
        Code Smell
        • convention

        Why is this an issue?

        Putting multiple statements on a single line lowers the code readability and makes debugging the code more complex.

        foo(); bar(); // Noncompliant
        

        Write one statement per line to improve readability.

        foo();
        bar();
        
          Available In:
        • SonarQube IdeCatch issues on the fly,
          in your IDE
        • SonarQube CloudDetect issues in your GitHub, Azure DevOps Services, Bitbucket Cloud, GitLab repositories
        • SonarQube Community BuildAnalyze code in your
          on-premise CI
          Available Since
          9.1
        • SonarQube ServerAnalyze code in your
          on-premise CI
          Developer Edition
          Available Since
          9.1

        © 2026 SonarSource Sàrl. All rights reserved.

        Privacy Policy | Cookie Policy | Terms of Use