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: 13 rules found
apex
    Impact
      Clean code attribute
        1. SOSL queries in test methods should use "Test.setFixedSearchResults"

           Code Smell
        2. DML operations in catch blocks can mask original exceptions

           Bug
        3. Future methods must be static and return void

           Bug
        4. Test classes should have only one @testSetup method

           Bug
        5. Test classes and methods should not use "seeAllData=true"

           Code Smell
        6. Classes implementing "Database.Batchable" should be declared as "global"

           Bug
        7. "getRoleAndSubordinates()" should be replaced with "getRoleAndSubordinatesInternal()"

           Code Smell
        8. Future methods making HTTP callouts should include "callout=true" parameter

           Bug
        9. Test classes should be annotated with "@isTest"

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

           Bug
        11. Private members made public for testing should use "@TestVisible" annotation

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

           Bug
        13. Test methods should not have parameters

           Bug

        Test methods should not have parameters

        intentionality - logical
        reliability
        maintainability
        Bug
        • apex
        • tests

        This rule raises an issue when a test method (annotated with @isTest or using the testMethod keyword) is declared with one or more parameters.

        Why is this an issue?

        How can I fix it?

        More Info

        The Apex testing framework has strict requirements for test method signatures. Test methods must not take any arguments to be recognized and executed by the framework.

        When a test method is declared with parameters, the Apex testing framework will not recognize it as a valid test method. This means the test will be silently ignored during test execution, leading to several problems:

        • The test will never run, providing false confidence that your code is working correctly
        • Code coverage metrics will be inaccurate since the test isn’t actually executing
        • Bugs in the code being tested may go undetected
        • Deployment to production may fail if actual code coverage falls below required thresholds

        The framework expects test methods to follow a specific syntax pattern that does not include parameters. This design ensures that tests are self-contained and can be executed automatically without requiring external input.

        What is the potential impact?

        Test methods with parameters will not be executed by the Apex testing framework, leading to false confidence in code quality and potentially allowing buggy code to be deployed to production. This can result in runtime failures and reduced application reliability.

          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