The "Possible Overflow" warning is great!

but trying to solve it, this doesn't seem to remove the warning:

while this does:

Also noticed MAXSTRLEN value is not respected, i.e.
_ApplicationAreaSetup."Company Name" := CopyStr(CompanyName(),1,MAXSTRLEN(ApplicationAreaSetup."Company Name"));_
The current analyzer rules are some test samples from an older internal C/AL analyzer tools. The use of CopyStr() is the way to suppress the warning in that tool. There are many other way to prevent an overflow, but only CopyStr() will suppress.
We may, in the future, want to replace the CopyStr approach with another construct that automatically uses the length from the target of the assignment.
Please remember that the Analyzer & rules are experimental and proof of concept. The analyzer (and the ability to write custom rules) are on the roadmap, but we are currently prioritizing other work.
We use this type of logic for the assigning of values to Text fields.:
SalesLine.Description := COPYSTR(SUBSTRNO(Text000, "No."), 1, MAXSTRLEN(SalesLine.Description));
Which currently causes the code analysis to emit:
Possible overflow assigning 'Text' to 'Text[50]'.
Will it be possible for the code analysis tool to recognize this type of construct? _Hard coding_ the Length parameter is not recommended practice.
This has been fixed in the BC Fall 2018 release. All 3 of the below will no longer generate this warning:
app."Company Name" := CompanyName().Substring(1, 30);
app."Company Name" := CopyStr(CompanyName(), 1, 30);
app."Company Name" := CopyStr(CompanyName(), 1, MaxStrLen(app."Company Name"));
Most helpful comment
We use this type of logic for the assigning of values to Text fields.:
SalesLine.Description := COPYSTR(SUBSTRNO(Text000, "No."), 1, MAXSTRLEN(SalesLine.Description));Which currently causes the code analysis to emit:
Possible overflow assigning 'Text' to 'Text[50]'.Will it be possible for the code analysis tool to recognize this type of construct? _Hard coding_ the
Lengthparameter is not recommended practice.