Detect missing NO-ERROR on FIND ... IF AVAILABLE
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.
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
Hello ! I close this issue, the rule "FindNoError" should solve your case. Feel free to update this issue if not.
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)"
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.