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
configuration
    Impact
      Clean code attribute
        1. URLs should not be hardcoded in Apex code

           Bug

        URLs should not be hardcoded in Apex code

        consistency - conventional
        reliability
        maintainability
        Bug
        • salesforce
        • configuration

        This rule raises an issue when URLs are hardcoded as string literals in Apex code, whether they are Salesforce instance URLs or external service endpoints.

        Why is this an issue?

        How can I fix it?

        More Info

        Hardcoded URLs in Apex code create several problems that affect maintainability, security, and reliability.

        When URLs are embedded directly in the code as string literals, they become difficult to manage across different environments. Development, staging, and production environments often use different endpoints, and hardcoded URLs require code changes to switch between them.

        For Salesforce instance URLs specifically, hardcoding creates a critical issue with My Domain enforcement. Salesforce is phasing out legacy host names and requiring all API calls to use My Domain URLs. Hardcoded instance URLs like na1.salesforce.com will break when My Domain enforcement is applied, causing API failures and integration issues.

        External service URLs present additional challenges. Hardcoded external endpoints make it difficult to implement proper security controls, rotate API endpoints, or manage different service configurations across environments. They also make the code less flexible and harder to test with mock services.

        From a security perspective, hardcoded URLs can expose sensitive endpoints in the source code and make it harder to implement centralized URL management and monitoring.

        What is the potential impact?

        Applications may break when Salesforce enforces My Domain requirements, causing API failures and integration issues. Hardcoded external URLs reduce flexibility in managing different environments and make it difficult to implement proper security controls or rotate endpoints when needed.

          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