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

Conversion could overflow variable - value XXXX too large to fit in INTEGER

Open dominickdm opened this issue 3 years ago • 2 comments

Hi,

The following code snippet is not violating the 'Conversion could overflow variable' rule, although it could lead to runtime errors like value XXXX too large to fit in INTEGER (15747).

DEFINE VARIABLE TheInt AS INT64 NO-UNDO.
DEFINE VARIABLE TheString AS CHARACTER NO-UNDO.

TheString = "123456789123456789":U.

TheInt = INTEGER(TheString).

Could the rule be extended in order to also detect this?

Background information: we are refactoring our application to have INT64's primary id fields in each table (in stead of INTEGER before).

Thank you for any feedback, Dominick

dominickdm avatar Sep 22 '22 13:09 dominickdm

Congratulations for issue #1000 😃 🎆 🎆🎆

gquerret avatar Sep 22 '22 13:09 gquerret

Technically, that could also overflow INT64, so it would be difficult to include that directly in the rule. It's not very difficult to have a rule that detects assignment of INT(char) function to INT or INT64, but I'm not sure if that would be really useful, the number of FP would probably be very high.

gquerret avatar Sep 22 '22 13:09 gquerret

Change added in develop, will be included in next release.

gquerret avatar Mar 06 '23 14:03 gquerret