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: 5 rules found
performance
    Impact
      Clean code attribute
        1. String conversions should use explicit methods instead of empty string concatenation

           Code Smell
        2. SOQL queries should not be executed inside loops

           Code Smell
        3. HTTP requests should have explicit timeout configuration

           Code Smell
        4. SOQL queries should use SystemModStamp instead of LastModifiedDate for better performance

           Code Smell
        5. Batch Apex scope parameters should not exceed 2000 records

           Code Smell

        Batch Apex scope parameters should not exceed 2000 records

        intentionality - efficient
        reliability
        Code Smell
        • salesforce
        • performance
        • batch

        This rule raises an issue when Database.executeBatch() is called with a scope parameter greater than 2000.

        Why is this an issue?

        How can I fix it?

        More Info

        When executing batch jobs in Salesforce, the scope parameter determines how many records are processed in each batch execution. While Salesforce allows scope values up to 2000 and will automatically chunk larger values into smaller batches, specifying excessively large scope parameters can lead to several problems.

        First, larger batch sizes increase the risk of hitting governor limits within a single batch execution. Each batch execution has its own set of governor limits for DML operations, SOQL queries, and CPU time. Processing too many records at once makes it more likely to exceed these limits, causing the batch job to fail.

        Second, performance can degrade with larger batch sizes. The Salesforce platform is optimized for processing smaller chunks of data efficiently. Larger batches can lead to longer execution times and increased memory usage, potentially affecting overall system performance.

        Finally, using appropriate batch sizes improves error handling and recovery. If a batch fails, smaller scope sizes mean fewer records need to be reprocessed, making debugging and recovery more manageable.

        What is the potential impact?

        Using excessively large batch scope parameters can cause batch jobs to fail due to governor limit violations, degrade system performance, and make error recovery more difficult. This can lead to incomplete data processing and unreliable batch operations.

          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