Error-prone: Check for redundant Collection.contains calls.

Created on 26 Jan 2018  路  2Comments  路  Source: google/error-prone

Could Error prone check for a Collection.contains call followed by an immediate Collection.remove call?

I see a fair amount of

if (myList.contains(value)) {
  myList.remove(value);
  // Do something.
}

which could be

if (myList.remove(value)) {
  // Do something.
}
Type-NewCheck

Most helpful comment

Or add (on Set)! Or put (on Map)!

All 2 comments

Or add (on Set)! Or put (on Map)!

This is internally covered in the tools alluded to in #649 which we are working on getting open sourced.

Was this page helpful?
0 / 5 - 0 ratings