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: 1 rule found
validation
    Impact
      Clean code attribute
        1. "String.isEmpty()" should be replaced with "String.isBlank()" for comprehensive validation

           Code Smell

        "String.isEmpty()" should be replaced with "String.isBlank()" for comprehensive validation

        intentionality - logical
        reliability
        maintainability
        Code Smell
        • validation
        • string-handling

        This rule raises an issue when String.isEmpty() is used to validate strings that should also reject whitespace-only content.

        Why is this an issue?

        How can I fix it?

        More Info

        The String.isEmpty() method only checks if a string is null or has zero length. It does not consider strings containing only whitespace characters as empty, which can lead to unexpected behavior in validation logic.

        For example, a string containing only spaces (' ') will return false when checked with isEmpty(), even though it contains no meaningful content. This can cause issues in:

        • User input validation where whitespace-only entries should be rejected
        • Data processing where empty fields need to be identified
        • Business logic that depends on meaningful string content

        The String.isBlank() method provides more comprehensive validation by returning true for null strings, empty strings, and strings containing only whitespace characters. This makes it the better choice when you need to ensure a string contains actual content.

        What is the potential impact?

        Using isEmpty() instead of isBlank() can lead to validation bypasses where whitespace-only strings are incorrectly treated as valid input. This may result in poor data quality, unexpected application behavior, or business logic errors when processing user input or data fields.

          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