Skip to content

Latest commit

 

History

History
71 lines (50 loc) · 1.48 KB

prefer-is-not-to-not-is.md

File metadata and controls

71 lines (50 loc) · 1.48 KB

code pal for ABAP > Documentation > Prefer IS NOT to NOT IS

Prefer IS NOT to NOT IS

What is the intent of the check?

Prefer IS ... NOT to NOT ... IS because it requires a "mental turnaround" that makes it harder to understand the negation logic.

How to solve the issue?

Preferably, use a positive condition; but if the negative condition is easier to understand, change the NOT ... IS to IS ... NOT.

What to do in case of exception?

In exceptional cases, you can suppress this finding by using the pseudo comment "#EC PREFER_IS_NOT:

  IF NOT variable IS INITIAL. "#EC PREFER_IS_NOT
  ENDIF.
  IF NOT variable CP 'TODO*'. "#EC PREFER_IS_NOT
  ENDIF.
  IF NOT variable = 42. "#EC PREFER_IS_NOT
  ENDIF.

Example

Before the check:

  IF NOT variable IS INITIAL.
  ENDIF.
  IF NOT variable CP 'TODO*'.
  ENDIF.
  IF NOT variable = 42.
  ENDIF.

After the check:

  IF variable IS NOT INITIAL.
  ENDIF.
  IF variable NP 'TODO*'.
  ENDIF.
  IF variable <> 42.
  ENDIF.

Further Readings & Knowledge