al-code-outline icon indicating copy to clipboard operation
al-code-outline copied to clipboard

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

Open jhoek opened this issue 1 year ago • 1 comments

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!

jhoek avatar Feb 20 '24 14:02 jhoek

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

dannoe avatar Mar 05 '24 08:03 dannoe