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
testing
    Impact
      Clean code attribute
        1. Arguments to "assertEquals" and "assertNotEquals" should be in the correct order

           Code Smell
        2. SOSL queries in test methods should use "Test.setFixedSearchResults"

           Code Smell
        3. Test classes and methods should not use "seeAllData=true"

           Code Smell
        4. Private members made public for testing should use "@TestVisible" annotation

           Code Smell
        5. Test methods should include meaningful assertions

           Code Smell

        Test methods should include meaningful assertions

        intentionality - complete
        reliability
        maintainability
        Code Smell
        • testing

        This rule raises an issue when an Apex test method (annotated with @isTest) does not contain any assertion statements (System.assert, System.assertEquals, or System.assertNotEquals).

        Why is this an issue?

        How can I fix it?

        More Info

        Test methods without assertions provide no validation of functionality and serve only to achieve code coverage without ensuring correctness. The primary purpose of unit testing is to verify that code behaves as expected under various conditions.

        When a test method executes code but doesn’t assert any expected outcomes, it fails to fulfill this fundamental purpose. Such tests can give developers a false sense of security, as they appear to be testing the code but actually provide no verification that the functionality works correctly.

        Meaningful assertions validate specific expected behaviors, such as:

        • Verifying that objects are created with correct field values
        • Ensuring that calculations produce expected results
        • Confirming that exceptions are thrown under appropriate conditions
        • Checking that database operations complete successfully

        Without these validations, bugs can easily slip through the testing process undetected. A test that simply executes code without verifying results is essentially worthless for quality assurance purposes.

        What is the potential impact?

        Tests without assertions can lead to several serious consequences:

        • False confidence: Developers may believe their code is properly tested when it actually lacks meaningful validation
        • Undetected bugs: Issues in the code may go unnoticed because no assertions verify correct behavior
        • Poor code quality: Without proper validation, defects can make it to production environments
        • Maintenance difficulties: When code changes break functionality, tests without assertions won’t catch the regressions
        • Wasted effort: Time spent writing and maintaining tests that provide no actual verification value
          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