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
ABAP

ABAP static code analysis

Unique rules to find Bugs, Vulnerabilities, Security Hotspots, and Code Smells in your ABAP code

  • All rules 94
  • Vulnerability4
  • Bug14
  • Security Hotspot7
  • Code Smell69
Filtered: 2 rules found
error-handling
    Impact
      Clean code attribute
        1. "CX_ROOT" should not be caught

           Code Smell
        2. "SY-SUBRC" should be tested after each statement setting it.

           Code Smell

        "SY-SUBRC" should be tested after each statement setting it.

        intentionality - complete
        maintainability
        Code Smell
        • error-handling

        Why is this an issue?

        The system field SY-SUBRC must be tested immediately after any statement setting this variable. Reading this variable informs on previous operation success or errors. Such errors should be handled properly so that the program continues in a consistent state.

        This rule raises an issue when the field SY-SUBRC is not checked just after performing one of the following operations:

        • Calling a function or method which can throw exceptions.
        • Calling one of the file access operation OPEN DATASET, READ DATASET or DELETE DATASET.

        SY-SUBRC check must be done either with the CASE, IF or CHECK statement.

        Noncompliant code example

        In the following case nothing happens if the exceptions NOT_FOUND or OTHERS are raised:

        CALL FUNCTION 'STRING_SPLIT'
          EXPORTING
            DELIMITER = ':'
            STRING = FELD
          IMPORTING
            HEAD =   HEAD
            TAIL = TAIL
          EXCEPTIONS
            NOT_FOUND = 1
            OTHERS = 2.
        

        Compliant solution

        CALL FUNCTION 'STRING_SPLIT'
          EXPORTING
            DELIMITER = ':'
            STRING = FELD
          IMPORTING
            HEAD =   HEAD
            TAIL = TAIL
          EXCEPTIONS
            NOT_FOUND = 1
            OTHERS = 2.
        CASE SY-SUBRC.
          WHEN 1. ...
          WHEN 2. ...
          WHEN OTHER.
        ENDCASE.
        

        Exceptions

        No issue will be raised in the following cases:

        • One or more WRITE operation are performed between the statement setting SY-SUBRC and its check. An exception will be however raised if the WRITE operation is a WRITE ... TO, as this will set SY-SUBRC too.
        • SY-SUBRC's value is assigned to a variable. We then assume that it will be checked later.
        OPEN DATASET my_dataset FOR INPUT IN TEXT MODE ENCODING DEFAULT. " Compliant
        WRITE 'Test'. " WRITE is accepted before checking SY-SUBRC
        IF SY-SUBRC <> 0.
            EXIT.
        ENDIF.
        
        OPEN DATASET my_dataset FOR INPUT IN TEXT MODE ENCODING DEFAULT. " Compliant
        Tmp = SY-SUBRC. " Assigning SY-SUBRC value to a variable. We assume that it will be checked later.
        IF Tmp <> 0.
            EXIT.
        ENDIF.
        
          Available In:
        • SonarQube IdeCatch issues on the fly,
          in your IDE
        • SonarQube CloudDetect issues in your GitHub, Azure DevOps Services, Bitbucket Cloud, GitLab repositories
        • SonarQube ServerAnalyze code in your
          on-premise CI
          Developer Edition
          Available Since
          9.1

        © 2008-2025 SonarSource SA. All rights reserved.

        Privacy Policy | Cookie Policy | Terms of Use