codeql
codeql copied to clipboard
Improve `cpp/wrong-type-format-argument` by adding correct formatting specifier
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.
Hi @AMS21,
That's a great suggestion. Thank you! I've recorded this in an internal issue 🙂.
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...