codeql icon indicating copy to clipboard operation
codeql copied to clipboard

Improve `cpp/wrong-type-format-argument` by adding correct formatting specifier

Open AMS21 opened this issue 1 year ago • 2 comments
trafficstars

Description of the issue Currently the cpp/wrong-type-format-argument diagnostic displays something like this

This argument should be of type 'int' but is of type 'unsigned long'.

It would be even more helpful if the diagnostic message would include the correct formatting specifier so it would look something like this:

This argument should be of type 'int' but is of type 'unsigned long'. Consider using '%ul' instead.

For reference cppreference has a great table about which specifier is needed for which type.

AMS21 avatar Dec 06 '23 18:12 AMS21

Hi @AMS21,

That's a great suggestion. Thank you! I've recorded this in an internal issue 🙂.

MathiasVP avatar Dec 07 '23 09:12 MathiasVP

The Copilot Autofix suggestions based on CodeQL code scanning alerts kinda provide for this, although they don't always match up with what the CodeQL diagnostic says itself...

cooljeanius avatar Sep 22 '24 16:09 cooljeanius