Skip to content

Commit

Permalink
> 0 checks (#364)
Browse files Browse the repository at this point in the history
  • Loading branch information
mccartney authored May 16, 2020
1 parent e83ea4f commit a028b2b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
}

0 comments on commit a028b2b

Please sign in to comment.