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
Apex

Apex static code analysis

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

  • All rules 97
  • Vulnerability2
  • Bug26
  • Security Hotspot3
  • Code Smell66
Filtered: 6 rules found
governor-limits
    Impact
      Clean code attribute
        1. SOQL queries should not be executed inside loops

           Code Smell
        2. HTTP requests should have explicit timeout configuration

           Code Smell
        3. SOQL queries should include LIMIT clauses to prevent hitting governor limits

           Bug
        4. Email messages should be sent in batches

           Bug
        5. Tested code should be enclosed between "Test.StartTest()" and "Test.StopTest()"

           Code Smell
        6. DML statements should not be used inside loops

           Bug

        SOQL queries should include LIMIT clauses to prevent hitting governor limits

        intentionality - complete
        reliability
        maintainability
        Bug
        • salesforce
        • apex
        • governor-limits

        This rule raises an issue when a SOQL query lacks a LIMIT clause and could potentially return more than 50,000 records.

        Why is this an issue?

        How can I fix it?

        More Info

        Salesforce enforces a governor limit of 50,000 records per SOQL query to maintain platform performance and stability. When a query exceeds this limit, it throws a LimitException: Too many query rows: 50001 error, causing your code to fail.

        Unlimited queries pose several risks:

        • Runtime failures: Your application will crash when the query returns too many records
        • Performance degradation: Large result sets consume more memory and processing time
        • Unpredictable behavior: Query results may vary between environments based on data volume
        • Resource consumption: Excessive memory usage can impact other operations

        This limit is a hard governor limit in Salesforce, meaning it cannot be increased by contacting support. The only solution is to design queries that respect this constraint from the start.

        Queries without LIMIT clauses are particularly risky when:

        • Querying large standard objects like Account, Contact, or Lead
        • Using broad WHERE conditions that don’t significantly filter results
        • Working with custom objects that may grow over time
        • Running in production environments with substantial data volumes

        What is the potential impact?

        Applications will fail with runtime exceptions when queries exceed 50,000 records. This can cause business processes to halt, data synchronization to fail, and user workflows to break unexpectedly.

          Available In:
        • SonarQube CloudDetect issues in your GitHub, Azure DevOps Services, Bitbucket Cloud, GitLab repositories

        © 2008-2025 SonarSource SA. All rights reserved.

        Privacy Policy | Cookie Policy | Terms of Use