sonar-openedge icon indicating copy to clipboard operation
sonar-openedge copied to clipboard

Detect missing NO-ERROR on FIND ... IF AVAILABLE

Open lievendf opened this issue 1 year ago • 4 comments

When writing

FIND Order WHERE ... NO-LOCK.
IF AVAILABLE Order
THEN ...

Sonar should warn for a missing NO-ERROR, as the IF AVAILABLE will not be executed in case the record isn't found.

lievendf avatar Jan 18 '24 11:01 lievendf

Did you enable this rule ? https://sonar.riverside-software.fr/coding_rules?languages=oe&q=error&open=rssw-oe-main%3Aeu.rssw.antlr.proparse.checks.FindNoError

gquerret avatar Jan 25 '24 19:01 gquerret

Hello ! I close this issue, the rule "FindNoError" should solve your case. Feel free to update this issue if not.

cdelabriere avatar Sep 26 '25 08:09 cdelabriere

Hi @cdelabriere , I believe the rule FindNoError does not apply here. I explicitly don't want to use NO-ERROR in cases where I'm sure the record must exist, and therefore I would want to get an error if it isn't found. In this case I would like Sonar to warn me for the use of IF AVAILABLE, as that makes no sense there: either the record is found and the code continues, or it isn't and an error is raised and the next statement is not executed at all... Can this issue be reopened?

Edit: perhaps I need to rephrase my original proposal. Instead of "Sonar should warn for a missing NO-ERROR, as the IF AVAILABLE will not be executed in case the record isn't found." It should be "Sonar should warn about the use of IF AVAILABLE when no NO-ERROR was used (since when that line is executed it will always be available, or we would have jumped out of the current block)"

lievendf avatar Sep 26 '25 08:09 lievendf

Thank you for the explanations, I reopen this issue. It looks like a suggestion for a new rule. We'll analyse this case and get back to you.

cdelabriere avatar Sep 26 '25 08:09 cdelabriere