diff --git a/src/main/scala/com/sksamuel/scapegoat/inspections/collections/AvoidSizeNotEqualsZero.scala b/src/main/scala/com/sksamuel/scapegoat/inspections/collections/AvoidSizeNotEqualsZero.scala index da1f0a59..8e29d990 100644 --- a/src/main/scala/com/sksamuel/scapegoat/inspections/collections/AvoidSizeNotEqualsZero.scala +++ b/src/main/scala/com/sksamuel/scapegoat/inspections/collections/AvoidSizeNotEqualsZero.scala @@ -24,7 +24,7 @@ class AvoidSizeNotEqualsZero override def inspect(tree: Tree): Unit = { tree match { case Apply( - Select(Select(_, Length | Size), TermName("$bang$eq")), + Select(Select(_, Length | Size), TermName("$bang$eq") | TermName("$greater")), List(Literal(Constant(0))) ) => context.warn(tree.pos, self, tree.toString.take(100)) diff --git a/src/test/scala/com/sksamuel/scapegoat/inspections/collections/AvoidSizeNotEqualsZeroTest.scala b/src/test/scala/com/sksamuel/scapegoat/inspections/collections/AvoidSizeNotEqualsZeroTest.scala index 4691763e..f9d74e19 100644 --- a/src/test/scala/com/sksamuel/scapegoat/inspections/collections/AvoidSizeNotEqualsZeroTest.scala +++ b/src/test/scala/com/sksamuel/scapegoat/inspections/collections/AvoidSizeNotEqualsZeroTest.scala @@ -13,12 +13,17 @@ class AvoidSizeNotEqualsZeroTest extends InspectionTest { val isEmpty1 = List(1).size != 0 val isEmpty2 = List(1).length != 0 val isEmpty3 = Set(1).size != 0 - val isEmpty5 = Seq(1).size != 0 - val isEmpty6 = Seq(1).length != 0 + val isEmpty4 = Seq(1).size != 0 + val isEmpty5 = Seq(1).length != 0 + val isGreater1 = List(1).size > 0 + val isGreater2 = List(1).length > 0 + val isGreater3 = Set(1).size > 0 + val isGreater4 = Seq(1).size > 0 + val isGreater5 = Seq(1).length > 0 } """.stripMargin compileCodeSnippet(code) - compiler.scapegoat.feedback.warnings.size shouldBe 5 + compiler.scapegoat.feedback.warnings.size shouldBe 10 } } }