HairyFotr / linter

Static Analysis Compiler Plugin for Scala
Apache License 2.0
268 stars 34 forks source link

Warn when using isEmpty would be better #5

Closed non closed 11 years ago

non commented 11 years ago

Often I'll see code that does _.size == 0 or _.length == 0 when _.isEmpty would be better. It's good to get people into this habit since for some collections (notably List[_]) getting the size is an O(n) operation whereas checking emptiness is O(1).

HairyFotr commented 11 years ago

I agree with this check, but I'd like to add configuration to Linter first... until then I'm trying to keep the number of the potentionally nagging warnings down :)

So, right now I'll add it for the types where it really is a lot slower, and later I'll allow users to crank the warning up to all types, if they wish to.