<-- previous rule | overview | next rule -->
Transforms logical expressions to use IS NOT instead of NOT IS, if possible.
This rule is part of the essential profile, as it is explicitly demanded by the Clean ABAP Styleguide.
- (no options available for this rule)
METHOD prefer_is_not_to_not_is.
" simple cases
IF NOT iv_param IS SUPPLIED.
IF NOT <ls_data> IS ASSIGNED.
IF NOT lo_object IS BOUND.
IF NOT lo_object IS INSTANCE OF cl_any_class.
IF NOT lts_table[ a = 1
b = 2
c = 3 ]-field IS INITIAL.
" do nothing
ENDIF.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
" complex cases
IF NOT iv_param IS SUPPLIED
OR NOT iv_other_param IS SUPPLIED.
IF NOT <ls_data> IS ASSIGNED
OR ( NOT lo_object IS BOUND
AND NOT lo_object IS INSTANCE OF cl_any_class ).
" do nothing
ENDIF.
ENDIF.
ENDMETHOD.
Resulting code:
METHOD prefer_is_not_to_not_is.
" simple cases
IF iv_param IS NOT SUPPLIED.
IF <ls_data> IS NOT ASSIGNED.
IF lo_object IS NOT BOUND.
IF lo_object IS NOT INSTANCE OF cl_any_class.
IF lts_table[ a = 1
b = 2
c = 3 ]-field IS NOT INITIAL.
" do nothing
ENDIF.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
" complex cases
IF iv_param IS NOT SUPPLIED
OR iv_other_param IS NOT SUPPLIED.
IF <ls_data> IS NOT ASSIGNED
OR ( lo_object IS NOT BOUND
AND lo_object IS NOT INSTANCE OF cl_any_class ).
" do nothing
ENDIF.
ENDIF.
ENDMETHOD.