sonar-openedge
sonar-openedge copied to clipboard
Conversion can overflow with enums creates a lot of non issues
A lot of the issues we have with the conversion overflow rule come from enums where we save the value as int.
INTEGER(FooEnum:GetValue())
I guess in 99% of cases, enums don't have more than 2^32 values. If the enum has not more than 2^32 values, the rule should not create an issue.
The enum doesn't need to have more than 2^32 values, it just needs one member with a large value in its definition:
ENUM Direction:
DEFINE ENUM North = 8000000000
South
East
West.
END ENUM.
Why save as INTEGER(FooEnum:GetValue()) and not directly as FooEnum:GetValue() ?
You are correct, i didn't think about that.
Ok i want to reopen this, at least in our codebase, most enums don't have values that would overflow integer. Would it be possible to only flag enums that have values > int?
ENUM values are now read from rcode (only in v12, that won't work with v11 rcode). Rule will be modified later (so not for tomorrow's release).
This is still a huge source for false positives but i would rather not disable the rule since the LONGCHAR/STRING checks are very nice to have. Is there a chance for this to make one of the next version?
Found a clean way to implement that (which required some changes introduced recently). That will be fixed in next version.
Available in 2.24