diff --git a/.scalafmt.conf b/.scalafmt.conf index d849ba9a..ed0954dd 100644 --- a/.scalafmt.conf +++ b/.scalafmt.conf @@ -1,5 +1,5 @@ -version = "2.6.4" +version = "2.7.2" maxColumn = 110 docstrings = JavaDoc assumeStandardLibraryStripMargin = true diff --git a/build.sbt b/build.sbt index 64b89cac..02abe500 100644 --- a/build.sbt +++ b/build.sbt @@ -1,5 +1,5 @@ // compiler plugins -addCompilerPlugin("org.scalameta" % "semanticdb-scalac" % "4.3.20" cross CrossVersion.full) +addCompilerPlugin("org.scalameta" % "semanticdb-scalac" % "4.3.22" cross CrossVersion.full) name := "scalac-scapegoat-plugin" organization := "com.sksamuel.scapegoat" @@ -105,11 +105,11 @@ libraryDependencies ++= Seq( "org.scala-lang.modules" %% "scala-xml" % "1.3.0" excludeAll ( ExclusionRule(organization = "org.scala-lang") ), - "org.scala-lang.modules" %% "scala-collection-compat" % "2.1.6" excludeAll ( + "org.scala-lang.modules" %% "scala-collection-compat" % "2.2.0" excludeAll ( ExclusionRule(organization = "org.scala-lang") ), "org.scala-lang" % "scala-compiler" % scalaVersion.value % "test", - "org.scalatest" %% "scalatest" % "3.2.0" % "test", + "org.scalatest" %% "scalatest" % "3.2.2" % "test", "org.mockito" % "mockito-all" % "1.10.19" % "test", "joda-time" % "joda-time" % "2.10.6" % "test", "org.joda" % "joda-convert" % "2.2.1" % "test", diff --git a/project/plugins.sbt b/project/plugins.sbt index c41e35d8..5c86a533 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -2,8 +2,8 @@ resolvers += Classpaths.sbtPluginReleases addSbtPlugin("com.geirsson" % "sbt-ci-release" % "1.5.3") addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.14.10") -addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.0") -addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.9.19") +addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.2") +addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.9.21") addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.6.1") if (System.getProperty("add-scapegoat-plugin") == "true") 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 ec14c577..fbb59cc7 100644 --- a/src/main/scala/com/sksamuel/scapegoat/inspections/collections/AvoidSizeNotEqualsZero.scala +++ b/src/main/scala/com/sksamuel/scapegoat/inspections/collections/AvoidSizeNotEqualsZero.scala @@ -25,9 +25,9 @@ class AvoidSizeNotEqualsZero override def inspect(tree: Tree): Unit = { tree match { case Apply( - Select(Select(_, Length | Size), TermName("$bang$eq") | TermName("$greater")), + Select(Select(q, Length | Size), TermName("$bang$eq") | TermName("$greater")), List(Literal(Constant(0))) - ) => + ) if isTraversable(q) => context.warn(tree.pos, self, tree.toString.take(100)) case _ => continue(tree) } 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 f9d74e19..704f3792 100644 --- a/src/test/scala/com/sksamuel/scapegoat/inspections/collections/AvoidSizeNotEqualsZeroTest.scala +++ b/src/test/scala/com/sksamuel/scapegoat/inspections/collections/AvoidSizeNotEqualsZeroTest.scala @@ -25,5 +25,17 @@ class AvoidSizeNotEqualsZeroTest extends InspectionTest { compileCodeSnippet(code) compiler.scapegoat.feedback.warnings.size shouldBe 10 } + // github issue #414 + "should ignore durations" in { + val code = """object Test { + |case class Duration(start: Long, stop: Long) { + | def length: Long = stop - start + | def nonEmpty: Boolean = length > 0 + | } + } """.stripMargin + + compileCodeSnippet(code) + compiler.scapegoat.feedback.warnings.size shouldBe 0 + } } }