cushon / issues-import

0 stars 0 forks source link

checking for a list.size() >= 0 #255

Open cushon opened 10 years ago

cushon commented 10 years ago

Original issue created by ahd@google.com on 2014-06-13 at 08:14 PM


Describe the bug pattern this checker should detect and why it is incorrect.

Note our criteria for new checks: https://github.com/cushon/issues-import/wiki/NewCheckCriteria

If possible, please attach source files that contain code that should and should not trigger the error. Code that should trigger the error should be in a file called PositiveCases.java, and code that should not trigger the error should be in a file called NegativeCases.java.

Otherwise, just include positive and negative cases below.

https://memegen.googleplex.com/4845295930179584

Yes, an error so bad it has a meme.

Here are samples, limited to Java:

https://cs.corp.google.com/#search/&sq=package:piper%20file://depot/google3%20-file:google3/(experimental%7Cobsolete)&q=%5C.size%5C(%5C)%5Cs?%3E=%5Cs?0%5C)%20lang:java&type=cs&m=100&sort=1

cushon commented 10 years ago

Original comment posted by eaftan@google.com on 2014-08-22 at 05:29 PM


We agree that this is terrible and probably should be a compiler error. The intent was probably to check for size > 0, so this is likely to indicate a bug.

It's probably reasonable to at least test this out for other fields and methods named size or length.


Status: Accepted