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: 3 rules found
soql
    Impact
      Clean code attribute
        1. SOQL queries should not contain hardcoded date literals

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

           Code Smell
        3. SOQL queries should be assigned to Lists to avoid QueryException

           Bug

        SOQL queries should use SystemModStamp instead of LastModifiedDate for better performance

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

        This rule raises an issue when SOQL queries filter records using the LastModifiedDate field in WHERE clauses.

        Why is this an issue?

        How can I fix it?

        More Info

        In Salesforce, query performance depends heavily on whether the query can use indexed fields. The platform automatically creates indexes on certain system fields to speed up data retrieval.

        LastModifiedDate is not indexed by default, which means queries filtering on this field require full table scans. When your organization has large amounts of data (over 100,000 records), these non-selective queries can become extremely slow or even fail due to governor limits.

        SystemModStamp, on the other hand, is automatically indexed by Salesforce. Both fields track when records were last modified, but SystemModStamp provides the same filtering capability with much better performance.

        The difference becomes critical in production environments with large datasets, where non-selective queries can cause timeouts, poor user experience, and may trigger Salesforce’s non-selective query prevention mechanisms.

        What is the potential impact?

        Using LastModifiedDate in SOQL queries can lead to:

        • Slow query execution times, especially with large datasets
        • Potential query timeouts and failures
        • Poor application performance and user experience
        • Risk of hitting Salesforce governor limits
        • Non-selective query errors when querying objects with more than 100,000 records
          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