weakchar

the "Weak Character" test

Rule "weakchar" gives this warning when it finds an ' IF charvar="" '
test that does not take into consideration that charvar might also
have the UNKNOWN value.

   IF AVAILABLE customer THEN
      IF customer.e-mail <> "" THEN
         RUN SendMail (customer.e-mail, subject, body).
      ELSE
         IF customer.fax <> "" THEN
            RUN SendFax (customer.fax, subject, body).

Trouble will happen if customer.e-mail happens to have the UNKNOWN value. The IF
condition did not check that.

So what is the proper way to check if a character field is not blanc
or unknown? You can think of several solutions, it is a matter of
taste or style, or perhaps even code-religion to pick the best. Here are a couple of
possible solutions:

   IF customer.e-mail > "" THEN ...

   IF NOT (customer.e-mail LE "") THEN ...
   
   IF NOT (customer.e-mail="" or customer.e-mail=?) THEN ...

   IF customer.e-mail<>"" AND customer.e-mail<>? THEN ...

This prolint rule gives probably many false positives and false negatives, it
needs improvement. One difficult issue is: what about the ELSE branche
of the IF statement?

How to suppress these warnings:

You can put the directive {&_proparse_ prolint-nowarn(weakchar)} directly before
the IF statement. See also: suppress warnings.