al-code-outline
al-code-outline copied to clipboard
Warning/error if no. of placeholders does not match no. of arguments
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!
This is already reported from the codecop analyzer AA0131. No extra extension necessary:
https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/analyzers/codecop-aa0131