microsoft / AL

Home of the Dynamics 365 Business Central AL Language extension for Visual Studio Code. Used to track issues regarding the latest version of the AL compiler and developer tools available in the Visual Studio Code Marketplace or as part of the AL Developer Preview builds for Dynamics 365 Business Central.
MIT License
744 stars 245 forks source link

Suggestion: Report an 'unused function' as an 'Info' message #2868

Closed bvbeek closed 2 years ago

bvbeek commented 6 years ago

That would be nice: 😀

StanislawStempin commented 5 years ago

I assume this would only apply to local functions? Public functions might be used outside of the compilation scope so not possible to detect while compiling the individual project.

bvbeek commented 5 years ago

I understand what you mean but probably I got one scope. And then I want to know it on the global functions as well. The info may say something like this: Function may not be in use please check....

MODUSCarstenScholling commented 4 years ago

I feel I am too late, but a local function with no reference should show as a warning while (another rule) should show unused global procedures as info.

mjmatthiesen commented 4 years ago

It'd be a nice rule. A long time ago, I wrote an extension to figure out what was/wasn't local: https://marketplace.visualstudio.com/items?itemName=mmatthiesen.localize-lens

Source is available so you can modify as needed. Keep in mind you may want some things public for extensions that the base product doesn't use.

DavidFeldhoff commented 3 years ago

I think we should consider the access modifiers as well. So global procedures could be marked as unused if the codeunit is interal (or the procedure itself)

mazhelez commented 2 years ago

Issue has been addressed. Please see https://docs.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/analyzers/codecop-aa0228

Public and internal functions are okay to be unused. We have work planned to address unraised event.