cushon / issues-import

0 stars 0 forks source link

Preconditions.check{State,Argument} invalid format specifier #232

Open cushon opened 10 years ago

cushon commented 10 years ago

Original issue created by danielwh@google.com on 2014-02-20 at 01:56 AM


The format strings for Preconditions.check* only support %s, not things like %d

Should be a compile error to use an invalid format specifier for a Preconditions call.

Invalid: Preconditions.checkState(false, "Seven equals %d", 7);

Valid: Preconditions.checkState(false, "Seven equals %s", 7);

cushon commented 10 years ago

Original comment posted by eaftan@google.com on 2014-02-20 at 08:03 PM


Louis wrote this check a while back: https://github.com/cushon/issues-import/blob/master/core/src/main/java/com/google/errorprone/bugpatterns/PreconditionsTooManyArgs.java

But it is still experimental and needs some work, probably related to the suggested fixes. If you have some 20% time, you could run it over Google's codebase, make sure the check itself is correct and produces good fixes, and do the cleanup.

cushon commented 10 years ago

Original comment posted by eaftan@google.com on 2014-03-04 at 12:41 AM


Check is throwing exceptions, needs work. This is probably less important than the format string checker that rburny is working on.

We probably won't get to this, but I'm marking it as a 20% project for anyone who is interested.


Status: Started Owner: lowasser@google.com Labels: Twenty-percent