diff --git a/infer/documentation/issues/CHECKERS_PRINTF_ARGS.md b/infer/documentation/issues/CHECKERS_PRINTF_ARGS.md new file mode 100644 index 000000000..24654d5ae --- /dev/null +++ b/infer/documentation/issues/CHECKERS_PRINTF_ARGS.md @@ -0,0 +1,9 @@ +This error is reported when the argument types to a `printf` method do not match the format string. + +```java + void stringInsteadOfInteger(PrintStream out) { + out.printf("Hello %d", "world"); + } +``` + +Action: fix the mismatch between format string and argument types. diff --git a/infer/src/base/IssueType.ml b/infer/src/base/IssueType.ml index b3257c7b1..90e56b2dd 100644 --- a/infer/src/base/IssueType.ml +++ b/infer/src/base/IssueType.ml @@ -324,7 +324,10 @@ let checkers_immutable_cast = ~user_documentation:[%blob "../../documentation/issues/CHECKERS_IMMUTABLE_CAST.md"] -let checkers_printf_args = register_from_string ~id:"CHECKERS_PRINTF_ARGS" Error PrintfArgs +let checkers_printf_args = + register_from_string ~id:"CHECKERS_PRINTF_ARGS" Error PrintfArgs + ~user_documentation:[%blob "../../documentation/issues/CHECKERS_PRINTF_ARGS.md"] + let class_cast_exception = register_from_string ~visibility:Developer ~enabled:false ~id:"CLASS_CAST_EXCEPTION" Error