StefanMaron / BusinessCentral.LinterCop

Community driven code linter for AL (MS Dynamics 365 Business Central)
https://stefanmaron.com
MIT License
72 stars 29 forks source link

LC0035 - False Positive FlowField #694

Open pri-kise opened 1 month ago

pri-kise commented 1 month ago

I don't know why, but I receive the info for LC0035 for this field below although this field is added on two pages.

tableextension 50000 "PTE-XXX Time Sheet Header" extends "Time Sheet Header"
{
    fields
    {
        field(50000; "PTE-XXX Resource Unit Cost"; Decimal)
        {
            CalcFormula = lookup(Resource."Unit Cost" where("No." = field("Resource No.")));
            Caption = 'Resource Unit Cost';
            Editable = false;
            FieldClass = FlowField;
        }
    }
}
pri-kise commented 1 month ago

It's added on my own pages. Not on a pageextension..

Arthurvdv commented 1 month ago

I think this is related to https://github.com/StefanMaron/BusinessCentral.LinterCop/issues/669, where the rule has been improved to also be raised on additional scenario's.

ans-bar-bm commented 1 month ago

I don't think it is directly related to #669, although the extended rule may have surfaced this problem.

The issue is that currently there is a separation in the analysis logic, so that for fields on tableextensions only fields on pageextensions are considered. As @pri-kise clarified the fields exist on a standalone page, not a pageextension, so they are not "seen" by this rule. I think likewise the "reverse" case also does not work correctly, that is if you have a standalone table and related page, and you have a field in this table that does not exist directly on this page. If you now extend that page yourself (which can be done since the latest releases) with this one field, that pageextension field is also not "seen".

I've linked a PR to fix this issue, in the bit of testing i did it seems to work with those changes.

Arthurvdv commented 1 month ago

@ans-bar-bm, Thank you for looking into this and providing the PR for this 🙌

@pri-kise, I've merged this into the pre-release, where it should be resolved.

pri-kise commented 1 month ago

It's fixed and lgtm.

Arthurvdv commented 1 month ago

The version v0.30.28 of the LinterCop is now the latest release. Could you verify if this is now working as expected? If this is the case, you may close this issue.