BusinessCentral.LinterCop icon indicating copy to clipboard operation
BusinessCentral.LinterCop copied to clipboard

LC0017 triggers on Global Variable?

Open Mkublbock opened this issue 10 months ago • 3 comments

I have a global variable called "Difference" of type Decimal. When trying to assign a Value to Difference LC0017 triggers even though it is a Global Variable and no FlowField. I checked the Record that is used but the Record also doesn't have a field called "Difference".

Difference, DifferenceAfterCorrection, TotalActualCreditInsurance, TotalExpectedCreditInsurance : Decimal;

Image

Is that a bug from LC0017 or am I missing something?

Mkublbock avatar Jan 29 '25 08:01 Mkublbock

I believe this is a false positive, where the rule shouldn't raise a diagnostic on that.

Can you share a small code sample to reproduce this?

Arthurvdv avatar Jan 29 '25 09:01 Arthurvdv

Okay, so I tried a few different examples and it seems to be due to my dataitem in my Report. When I use the following code it works without any warnings:

Image

But as soon as I use a the "VDIT_Transaction" dataitem it shows the warning:

Image

So it seems like all Dataitems worked except "VDIT_Transaction". Unfortunately I cannot share the source code for "VDIT_Transaction". But I already checked the source for any occurrence of "Difference" where there are no results.

Any ideas what's causing this?

Mkublbock avatar Jan 29 '25 09:01 Mkublbock

The false positive is caused by something with the "VDIT_Transaction" table, where I'm completely in the dark on this.

You could try creating an new AL project and copy/paste over the table and report entity and bring it down to the minimum to reproduce this. Maybe the field definitions is enough, where you can remove procedures and/or triggers on the table.

Arthurvdv avatar Jan 29 '25 10:01 Arthurvdv

@Mkublbock, are you still running into this issue? If yes, did you by any chance have time to put together a minimal AL project to reproduce it?

Arthurvdv avatar May 13 '25 09:05 Arthurvdv

Hey @Arthurvdv, sorry for the late response. The issue still persists. I tried your approach of creating a new project and copy pasting over the VDIT_Transaction table. Interestingly the warning will not show then. I've have had to remove some lines because of missing dependencies though. So maybe the error was in one of these lines.

Mkublbock avatar Jun 20 '25 09:06 Mkublbock

Still, I don't know what's causing this wrong warning but I guess we'll just surround it with pragmas

Mkublbock avatar Jun 20 '25 09:06 Mkublbock