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
Python

Python static code analysis

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

  • All rules 414
  • Vulnerability45
  • Bug104
  • Security Hotspot50
  • Code Smell215

  • Quick Fix 33
Filtered: 33 rules found
convention
    Impact
      Clean code attribute
        1. Einops pattern should be valid

           Bug
        2. 'startswith' or 'endswith' methods should be used instead of string slicing in condition expressions

           Code Smell
        3. Built-in generic types should be preferred over the typing module in type hints

           Code Smell
        4. Type hints of generic types should specify their type parameters

           Code Smell
        5. Any should not be used as a type hint

           Code Smell
        6. Function parameters should have type hints

           Code Smell
        7. Function returns should have type hints

           Code Smell
        8. "self" should be the first argument to instance methods

           Code Smell
        9. Custom Exception classes should inherit from "Exception" or one of its subclasses

           Code Smell
        10. All branches in a conditional structure should not have exactly the same implementation

           Bug
        11. Non-existent operators like "=+" should not be used

           Bug
        12. "__init__" should not return a value

           Bug
        13. The first argument to class methods should follow the naming convention

           Code Smell
        14. Increment and decrement operators should not be used

           Bug
        15. Methods and field names should not differ only by capitalization

           Code Smell
        16. Docstrings should be defined

           Code Smell
        17. Track "TODO" and "FIXME" comments that do not contain a reference to a person

           Code Smell
        18. Variables should not be self-assigned

           Bug
        19. Module names should comply with a naming convention

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

           Code Smell
        21. Track lack of copyright and license headers

           Code Smell
        22. Comments should not be located at the end of lines of code

           Code Smell
        23. Track comments matching a regular expression

           Code Smell
        24. Statements should be on separate lines

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

           Code Smell
        26. Field names should comply with a naming convention

           Code Smell
        27. Lines should not end with trailing whitespaces

           Code Smell
        28. Files should end with a newline

           Code Smell
        29. Long suffix "L" should be upper case

           Code Smell
        30. Unnecessary imports should be removed

           Code Smell
        31. Lines should not be too long

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

           Code Smell
        33. Method names should comply with a naming convention

           Code Smell

        Type hints of generic types should specify their type parameters

        intentionality - clear
        maintainability
        Code Smell
        • convention
        • typing

        Why is this an issue?

        How can I fix it?

        More Info

        Generic types, such as list or dict accept type arguments to specify the type of elements contained in the list or the keys and values in the dictionary.

        If a generic type is used without a type argument, the type arguments will implicitly assumed to be Any. This makes the type hint less informative and makes the contract of the function or variable annotated with the type hint more difficult to understand.

        Furthermore, incomplete type hints can hinder IDE autocompletion and code insight capabilities of static analyis tools.

          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
          10.1
        • SonarQube ServerAnalyze code in your
          on-premise CI
          Developer Edition
          Available Since
          10.1

        © 2026 SonarSource Sàrl. All rights reserved.

        Privacy Policy | Cookie Policy | Terms of Use