SAP / abap-cleaner

ABAP cleaner applies 95+ cleanup rules to ABAP code at a single keystroke
Apache License 2.0
453 stars 48 forks source link

cx_assert does not exist #314

Closed cawoodmonads closed 4 months ago

cawoodmonads commented 5 months ago

There is a check that no ASSERT is used but instead cx_assert. However the class cx_assert does not exist in any SAP system we know of. How are users supposed to proceed? Create and configure a zcx_assert?

jmgrassau commented 5 months ago

Hello cawoodmonads,

yes, the reasoning behind this is as follows:

CLASS cx_xyz_assert DEFINITION PUBLIC
      INHERITING FROM cx_no_check FINAL
      CREATE PUBLIC.

  PUBLIC SECTION.
    METHODS constructor
      IMPORTING previous LIKE previous OPTIONAL.

    CLASS-METHODS assert_not_initial
      IMPORTING VALUE(act) TYPE any.

    " ...
ENDCLASS.

CLASS cx_xyz_assert IMPLEMENTATION.
  METHOD constructor.
    super->constructor( previous = previous ).
  ENDMETHOD.

  METHOD assert_not_initial.
    IF act IS INITIAL.
      RAISE EXCEPTION NEW cx_xyz_assert( ).
    ENDIF.
  ENDMETHOD.

  " ...
ENDCLASS.

Kind regards, Jörg-Michael

jmgrassau commented 5 months ago

P.S.: Putting the "documentation" label, because it would certainly be helpful to have a better explanation within the cleanup rule (e.g. in the example code)

jmgrassau commented 4 months ago

Hi cawoodmonads,

I meanwhile enhanced the examples of this cleanup rule with some explanation (similar to my comments above), so hopefully this is better understandable now. Thanks again for bringing it up – this is available now with version 1.18.0, which was just released!

Kind regards, Jörg-Michael