anzwdev / al-code-outline

AL Code Outline for Visual Studio Code
MIT License
51 stars 13 forks source link

Warning/error if no. of placeholders does not match no. of arguments #539

Open jhoek opened 6 months ago

jhoek commented 6 months ago

Would it be possible to issue a warning if the number of placeholders in the format string in e.g. Error, Confirm, StrSubstNo etc. does not match the number of arguments passed? E.g.

Too few parameters (error): StrSubstNo('%1 foo %2 baz %3', Qux, Quux);

To many parameters (warning?): Error('%1 foo', Baz, Bar);

Note that, strictly speaking, this is about the placeholders' indexes, not about the number of placeholders: StrSubstNo('%1 %1 %1', Foo); // should be perfectly valid, with just one placeholder argument (%1).

Thanks for considering my suggestion!

dannoe commented 6 months ago

This is already reported from the codecop analyzer AA0131. No extra extension necessary:

grafik

https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/analyzers/codecop-aa0131