StefanMaron / BusinessCentral.LinterCop

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

Added rule LC0052 and LC0053 Internal Procedures Not Referenced & Internal procedure only referenced from the defining object #514

Closed rvanbekkum closed 9 months ago

rvanbekkum commented 9 months ago

This PR adds the following new rules:

ID Description Additional Info Default Severity
LC0052 The internal method is declared but never used. Also detects unused public procedures in objects with Access = Internal. Info
LC0053 The internal method is only used in the object in which it is declared. Consider making the procedure local. Info

Default severity for now set to Info for both rules even though it is advised to have LC0052 as a warning.

Rule LC0052 and LC0053 will also raise diagnostics regardless of whether someone is using internalsVisibleTo in the app manifest. This is a deliberate choice. If you really need the internal procedure for your tests, then suppress the diagnostic for individual cases with a #pragma warning disable LC0052 // The procedure is used by the tests or #pragma warning disable LC0053 // The procedure is used by the tests

The rules will skip internal procedures that have a single parameter of type ErrorInfo or Notification.

rvanbekkum commented 9 months ago

Addresses #197

Arthurvdv commented 9 months ago

Thank you for the PR, it look great.

I'll go ahead an add this to the pre-release and will create the documentation in the wiki.