Uploaded image for project: 'SonarABAP'
  1. SonarABAP
  2. SONARABAP-414

Rule S1511 should also raise issues on CALL METHOD, not just CALL FUNCTION

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 3.9
    • Component/s: Rules
    • Labels:
      None

      Description

      SY-SUBRC should also be tested after a CALL METHOD statement which can raise an exception. Currently the rule only raises issues on CALL FUNCTION.

      Noncompliant code example

      CALL METHOD X1->Y1    " Noncompliant
        EXCEPTIONS 
          EXP1 = 10 
          EXP2 = 20.
      

      Compliant Solution

      CALL METHOD X1->Y1
        EXCEPTIONS 
          EXP1 = 10 
          EXP2 = 20.
      
      CASE SY-SUBRC.
        WHEN 1. ...
        WHEN 2. ...
        WHEN OTHER.
      ENDCASE.
      

      Messages

      The issue message should be '"SY-SUBRC must be tested after each call to "XXX->YYY"'
      We can at the same time improve the message for functions as follow: '"SY-SUBRC must be tested after each call to "XXX"'

      Rule description

      Once implemented, the rule description should be updated to say:

      ===

      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 DATASETREAD DATASET or DELETE DATASET.

      ===

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              roberto.orlandi Roberto Orlandi
              Reporter:
              nicolas.harraudeau Nicolas Harraudeau (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Due:
                Created:
                Updated:
                Resolved: