Skip to content

false positives: Prefer IS NOT to NOT IS #362

@jmgrassau

Description

@jmgrassau

Hello,

this check creates false positives for code like
IF NOT is_loaded( ).
where is_loaded( ) has an ABAP_BOOL returning parameter; or, for a more complex example,
IF is_new( ) AND NOT is_loaded( ).

I don't think the code would be better readable if I changed it to
IF is_loaded( ) = abap_false.
IF is_new( ) =abap_true AND is_loaded( ) = abap_false.
or is that what Clean ABAP recommends in such a case?

Similarly, the check creates messages for code like
IF NOT ( a < b AND c < d OR a > b AND c > d ).

Of course, you could replace this with
IF ( ( a >= b OR c >= d ) AND ( a <= b OR c <= d ) ).
but usually when if saw the IF NOT ( … ) syntax, there was a good reason for it, and the logical expression was easier to understand that way.

Anyway, such cases do not quite fit to the error message "Prefer IS NOT to NOT IS". Is this check simply searching the code for "IF NOT"? Maybe it could at least restrict the findings to cases where an actual "IS" appears somewhere in the logical expression …

Kind regards,
Jörg-Michael

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions