diff --git a/.github/workflows/pr-checks.yml b/.github/workflows/pr-checks.yml
index 68b832c0..7181c347 100644
--- a/.github/workflows/pr-checks.yml
+++ b/.github/workflows/pr-checks.yml
@@ -14,9 +14,9 @@ jobs:
- 2.12.11
- 2.12.12
- 2.12.13
- - 2.13.3
- 2.13.4
- 2.13.5
+ - 2.13.6
steps:
- uses: actions/checkout@v2
- uses: olafurpg/setup-scala@v10
diff --git a/README.md b/README.md
index 3447b6fa..bdacbe44 100644
--- a/README.md
+++ b/README.md
@@ -3,8 +3,8 @@ Scapegoat
[![Codecov](https://img.shields.io/codecov/c/github/sksamuel/scapegoat)](https://codecov.io/gh/sksamuel/scapegoat)
[](http://search.maven.org/#search%7Cga%7C1%7Ca%3A%22scalac-scapegoat-plugin_2.11.12%22)
-[](http://search.maven.org/#search%7Cga%7C1%7Ca%3A%22scalac-scapegoat-plugin_2.12.11%22)
-[](http://search.maven.org/#search%7Cga%7C1%7Ca%3A%22scalac-scapegoat-plugin_2.13.5%22)
+[](http://search.maven.org/#search%7Cga%7C1%7Ca%3A%22scalac-scapegoat-plugin_2.12.13%22)
+[](http://search.maven.org/#search%7Cga%7C1%7Ca%3A%22scalac-scapegoat-plugin_2.13.6%22)
[![Scala Steward badge](https://img.shields.io/badge/Scala_Steward-helping-blue.svg?style=flat&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAAQCAMAAAARSr4IAAAAVFBMVEUAAACHjojlOy5NWlrKzcYRKjGFjIbp293YycuLa3pYY2LSqql4f3pCUFTgSjNodYRmcXUsPD/NTTbjRS+2jomhgnzNc223cGvZS0HaSD0XLjbaSjElhIr+AAAAAXRSTlMAQObYZgAAAHlJREFUCNdNyosOwyAIhWHAQS1Vt7a77/3fcxxdmv0xwmckutAR1nkm4ggbyEcg/wWmlGLDAA3oL50xi6fk5ffZ3E2E3QfZDCcCN2YtbEWZt+Drc6u6rlqv7Uk0LdKqqr5rk2UCRXOk0vmQKGfc94nOJyQjouF9H/wCc9gECEYfONoAAAAASUVORK5CYII=)](https://scala-steward.org)
Scapegoat is a Scala static code analyzer, what is more colloquially known as a code lint tool or linter. Scapegoat works in a similar vein to Java's [FindBugs](http://findbugs.sourceforge.net/) or [checkstyle](http://checkstyle.sourceforge.net/), or Scala's [Scalastyle](https://github.com/scalastyle/scalastyle).
diff --git a/build.sbt b/build.sbt
index 8009bb29..db27d80b 100644
--- a/build.sbt
+++ b/build.sbt
@@ -22,8 +22,8 @@ developers := List(
)
)
-scalaVersion := "2.13.5"
-crossScalaVersions := Seq("2.11.12", "2.12.11", "2.12.14", "2.13.6", "2.13.3", "2.13.4", "2.13.5")
+scalaVersion := "2.13.6"
+crossScalaVersions := Seq("2.11.12", "2.12.12", "2.12.13", "2.12.14", "2.13.3", "2.13.4", "2.13.5", "2.13.6")
autoScalaLibrary := false
crossVersion := CrossVersion.full
crossTarget := {
@@ -75,18 +75,18 @@ scalacOptions := {
common ++ (scalaBinaryVersion.value match {
case "2.11" => scalac11Options
case "2.12" => scalac12Options
- case "2.13" => scalac13Options ++ (
- scalaVersion.value.split('.') match {
+ case "2.13" =>
+ scalac13Options ++ (scalaVersion.value.split('.') match {
case Array(_, _, patch) if Set("0", "1", "2")(patch) => Seq("-Xlint:nullary-override")
- case _ => Seq.empty[String]
+ case _ => Seq.empty[String]
})
})
}
javacOptions ++= Seq("-source", "1.8", "-target", "1.8")
// because that's where "PluginRunner" is
-fullClasspath in console in Compile ++= (fullClasspath in Test).value
-initialCommands in console := s"""
+Compile / console / fullClasspath ++= (Test / fullClasspath).value
+console / initialCommands := s"""
import com.sksamuel.scapegoat._
def check(code: String) = {
val runner = new PluginRunner { val inspections = ScapegoatConfig.inspections }
@@ -100,54 +100,49 @@ def check(code: String) = {
"""
libraryDependencies ++= Seq(
- "org.scala-lang" % "scala-reflect" % scalaVersion.value % "provided",
- "org.scala-lang" % "scala-compiler" % scalaVersion.value % "provided",
- "org.scala-lang.modules" %% "scala-xml" % "1.3.0" excludeAll (
- ExclusionRule(organization = "org.scala-lang")
- ),
- "org.scala-lang.modules" %% "scala-collection-compat" % "2.4.4" excludeAll (
- ExclusionRule(organization = "org.scala-lang")
+ "org.scala-lang" % "scala-reflect" % scalaVersion.value % "provided",
+ "org.scala-lang" % "scala-compiler" % scalaVersion.value % "provided",
+ "org.scala-lang.modules" %% "scala-xml" % "1.3.0" excludeAll ExclusionRule(organization = "org.scala-lang"),
+ "org.scala-lang.modules" %% "scala-collection-compat" % "2.4.4" excludeAll ExclusionRule(organization =
+ "org.scala-lang"
),
"org.scala-lang" % "scala-compiler" % scalaVersion.value % "test",
- "org.scalatest" %% "scalatest" % "3.2.9" % "test",
+ "org.scalatest" %% "scalatest" % "3.2.9" % "test",
"org.mockito" % "mockito-all" % "1.10.19" % "test",
- "joda-time" % "joda-time" % "2.10.10" % "test",
+ "joda-time" % "joda-time" % "2.10.10" % "test",
"org.joda" % "joda-convert" % "2.2.1" % "test",
"org.slf4j" % "slf4j-api" % "1.7.30" % "test"
)
// Test
-fork in (Test, run) := true
-logBuffered in Test := false
-parallelExecution in Test := false
+Test / run / fork := true
+Test / logBuffered := false
+Test / parallelExecution := false
// ScalaTest reporter config:
// -o - standard output,
// D - show all durations,
// T - show reminder of failed and cancelled tests with short stack traces,
// F - show full stack traces.
-testOptions in Test += Tests.Argument(TestFrameworks.ScalaTest, "-oDTF")
+Test / testOptions += Tests.Argument(TestFrameworks.ScalaTest, "-oDTF")
// Assembly
// include the scala xml and compat modules into the final jar, shaded
-assemblyShadeRules in assembly := Seq(
+assembly / assemblyShadeRules := Seq(
ShadeRule.rename("scala.xml.**" -> "scapegoat.xml.@1").inAll,
ShadeRule.rename("scala.collection.compat.**" -> "scapegoat.compat.@1").inAll
)
-packageBin in Compile := crossTarget.value / (assemblyJarName in assembly).value
+Compile / packageBin := crossTarget.value / (assembly / assemblyJarName).value
makePom := makePom.dependsOn(assembly).value
-test in assembly := {} // do not run tests during assembly
-publishArtifact in Test := false
+assembly / test := {} // do not run tests during assembly
+Test / publishArtifact := false
// Scalafix
-scalafixDependencies in ThisBuild += "com.nequissimus" %% "sort-imports" % "0.3.1"
+ThisBuild / scalafixDependencies += "com.nequissimus" %% "sort-imports" % "0.3.1"
addCommandAlias("fix", "all compile:scalafix test:scalafix; fixImports")
addCommandAlias("fixImports", "compile:scalafix SortImports; test:scalafix SortImports")
addCommandAlias("fixCheck", "compile:scalafix --check; test:scalafix --check; fixCheckImports")
addCommandAlias("fixCheckImports", "compile:scalafix --check SortImports; test:scalafix --check SortImports")
// Scalafmt
-scalafmtOnCompile in ThisBuild :=
- sys.env
- .get("GITHUB_ACTIONS")
- .forall(_.toLowerCase == "false")
+ThisBuild / scalafmtOnCompile := sys.env.get("GITHUB_ACTIONS").forall(_.toLowerCase == "false")
diff --git a/src/main/scala/com/sksamuel/scapegoat/Feedback.scala b/src/main/scala/com/sksamuel/scapegoat/Feedback.scala
index 2191f324..dde1beb2 100644
--- a/src/main/scala/com/sksamuel/scapegoat/Feedback.scala
+++ b/src/main/scala/com/sksamuel/scapegoat/Feedback.scala
@@ -20,9 +20,9 @@ class Feedback(
def shouldPrint(warning: Warning): Boolean =
configuration.consoleOutput && warning.hasMinimalLevelOf(configuration.minimalLevel)
- def infos = warnings(Levels.Info)
- def errors = warnings(Levels.Error)
- def warns = warnings(Levels.Warning)
+ def infos: Seq[Warning] = warnings(Levels.Info)
+ def errors: Seq[Warning] = warnings(Levels.Error)
+ def warns: Seq[Warning] = warnings(Levels.Warning)
def warnings(level: Level): Seq[Warning] = warnings.filter(_.level == level)
def warn(
diff --git a/src/main/scala/com/sksamuel/scapegoat/Inspection.scala b/src/main/scala/com/sksamuel/scapegoat/Inspection.scala
index 19237681..476e9d36 100644
--- a/src/main/scala/com/sksamuel/scapegoat/Inspection.scala
+++ b/src/main/scala/com/sksamuel/scapegoat/Inspection.scala
@@ -13,7 +13,7 @@ abstract class Inspection(
val explanation: String
) {
- val self = this
+ val self: Inspection = this
def inspector(context: InspectionContext): Inspector
@@ -88,7 +88,7 @@ final case class InspectionContext(global: Global, feedback: Feedback) {
symbol != null &&
symbol.annotations.exists(an => isSkipAnnotation(an) && isThisDisabled(an))
- protected def continue(tree: Tree) = super.traverse(tree)
+ protected def continue(tree: Tree): Unit = super.traverse(tree)
protected def inspect(tree: Tree): Unit
@@ -109,7 +109,7 @@ final case class InspectionContext(global: Global, feedback: Feedback) {
}
protected def isArray(tree: Tree): Boolean = tree.tpe.typeSymbol.fullName == "scala.Array"
- protected def isTraversable(tree: Tree): Boolean = tree.tpe <:< typeOf[Traversable[Any]]
+ protected def isIterable(tree: Tree): Boolean = tree.tpe <:< typeOf[Iterable[Any]]
protected def isSeq(t: Tree): Boolean = t.tpe <:< typeOf[Seq[Any]]
protected def isIndexedSeq(t: Tree): Boolean = t.tpe <:< typeOf[IndexedSeq[Any]]
protected def isSet(t: Tree, allowMutableSet: Boolean = true): Boolean = {
diff --git a/src/main/scala/com/sksamuel/scapegoat/inspections/VariableShadowing.scala b/src/main/scala/com/sksamuel/scapegoat/inspections/VariableShadowing.scala
index 6ce9438c..1d5d104c 100644
--- a/src/main/scala/com/sksamuel/scapegoat/inspections/VariableShadowing.scala
+++ b/src/main/scala/com/sksamuel/scapegoat/inspections/VariableShadowing.scala
@@ -1,6 +1,5 @@
package com.sksamuel.scapegoat.inspections
-import scala.collection.mutable
import scala.collection.mutable.ListBuffer
import com.sksamuel.scapegoat.{Inspection, InspectionContext, Inspector, Levels}
@@ -16,17 +15,17 @@ class VariableShadowing
def inspector(context: InspectionContext): Inspector =
new Inspector(context) {
- override def postTyperTraverser =
+ override def postTyperTraverser: context.Traverser =
new context.Traverser {
import context.global._
- private val contexts = new mutable.Stack[ListBuffer[String]]()
+ private var contexts: List[ListBuffer[String]] = Nil
private def isDefined(name: String): Boolean = contexts exists (_.contains(name.trim))
- private def enter(): Unit = contexts.push(new ListBuffer[String])
- private def exit(): Unit = contexts.pop()
+ private def enter(): Unit = contexts = new ListBuffer[String] :: contexts
+ private def exit(): Unit = contexts = contexts.drop(1)
override def inspect(tree: Tree): Unit = {
tree match {
@@ -43,7 +42,7 @@ class VariableShadowing
exit()
case ValDef(_, TermName(name), _, _) =>
if (isDefined(name)) context.warn(tree.pos, self, tree.toString.take(200))
- contexts.top.append(name.trim)
+ contexts.head.append(name.trim)
case Match(_, cases) =>
cases.foreach {
case CaseDef(Bind(name, _), _, _) =>
diff --git a/src/main/scala/com/sksamuel/scapegoat/inspections/collections/AvoidSizeEqualsZero.scala b/src/main/scala/com/sksamuel/scapegoat/inspections/collections/AvoidSizeEqualsZero.scala
index 87dc9fc8..65100c28 100644
--- a/src/main/scala/com/sksamuel/scapegoat/inspections/collections/AvoidSizeEqualsZero.scala
+++ b/src/main/scala/com/sksamuel/scapegoat/inspections/collections/AvoidSizeEqualsZero.scala
@@ -16,7 +16,7 @@ class AvoidSizeEqualsZero
def inspector(context: InspectionContext): Inspector =
new Inspector(context) {
- override def postTyperTraverser =
+ override def postTyperTraverser: context.Traverser =
new context.Traverser {
import context.global._
@@ -27,7 +27,7 @@ class AvoidSizeEqualsZero
override def inspect(tree: Tree): Unit = {
tree match {
case Apply(Select(Select(q, Size | Length), TermName("$eq$eq")), List(Literal(Constant(0))))
- if isTraversable(q) =>
+ if isIterable(q) =>
context.warn(tree.pos, self, tree.toString.take(100))
case _ => continue(tree)
}
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 8676e2c2..3a15d1fa 100644
--- a/src/main/scala/com/sksamuel/scapegoat/inspections/collections/AvoidSizeNotEqualsZero.scala
+++ b/src/main/scala/com/sksamuel/scapegoat/inspections/collections/AvoidSizeNotEqualsZero.scala
@@ -15,7 +15,7 @@ class AvoidSizeNotEqualsZero
def inspector(context: InspectionContext): Inspector =
new Inspector(context) {
- override def postTyperTraverser =
+ override def postTyperTraverser: context.Traverser =
new context.Traverser {
import context.global._
@@ -28,7 +28,7 @@ class AvoidSizeNotEqualsZero
case Apply(
Select(Select(q, Length | Size), TermName("$bang$eq") | TermName("$greater")),
List(Literal(Constant(0)))
- ) if isTraversable(q) =>
+ ) if isIterable(q) =>
context.warn(tree.pos, self, tree.toString.take(100))
case _ => continue(tree)
}
diff --git a/src/main/scala/com/sksamuel/scapegoat/inspections/collections/ExistsSimplifiableToContains.scala b/src/main/scala/com/sksamuel/scapegoat/inspections/collections/ExistsSimplifiableToContains.scala
index 4acbef65..5f18943d 100644
--- a/src/main/scala/com/sksamuel/scapegoat/inspections/collections/ExistsSimplifiableToContains.scala
+++ b/src/main/scala/com/sksamuel/scapegoat/inspections/collections/ExistsSimplifiableToContains.scala
@@ -17,7 +17,7 @@ class ExistsSimplifiableToContains
def inspector(context: InspectionContext): Inspector =
new Inspector(context) {
- override def postTyperTraverser =
+ override def postTyperTraverser: context.Traverser =
new context.Traverser {
import context.global._
@@ -26,7 +26,7 @@ class ExistsSimplifiableToContains
private def doesElementTypeMatch(container: Tree, value: Tree): Boolean = {
val valueType = value.tpe.underlying.typeSymbol.tpe
- val traversableType = container.tpe.underlying.baseType(typeOf[Traversable[Any]].typeSymbol)
+ val traversableType = container.tpe.underlying.baseType(typeOf[Iterable[Any]].typeSymbol)
traversableType.typeArgs.exists(t => valueType <:< t || valueType =:= t)
}
diff --git a/src/main/scala/com/sksamuel/scapegoat/inspections/collections/NegationIsEmpty.scala b/src/main/scala/com/sksamuel/scapegoat/inspections/collections/NegationIsEmpty.scala
index 2700a5aa..a0f7939c 100644
--- a/src/main/scala/com/sksamuel/scapegoat/inspections/collections/NegationIsEmpty.scala
+++ b/src/main/scala/com/sksamuel/scapegoat/inspections/collections/NegationIsEmpty.scala
@@ -15,7 +15,7 @@ class NegationIsEmpty
def inspector(context: InspectionContext): Inspector =
new Inspector(context) {
- override def postTyperTraverser =
+ override def postTyperTraverser: context.Traverser =
new context.Traverser {
import context.global._
@@ -25,7 +25,7 @@ class NegationIsEmpty
override def inspect(tree: Tree): Unit = {
tree match {
- case Select(Select(lhs, IsEmpty), Bang) if isTraversable(lhs) =>
+ case Select(Select(lhs, IsEmpty), Bang) if isIterable(lhs) =>
context.warn(tree.pos, self, tree.toString.take(100))
case _ => continue(tree)
}
diff --git a/src/main/scala/com/sksamuel/scapegoat/inspections/collections/NegationNonEmpty.scala b/src/main/scala/com/sksamuel/scapegoat/inspections/collections/NegationNonEmpty.scala
index cf8f888d..7b01bedd 100644
--- a/src/main/scala/com/sksamuel/scapegoat/inspections/collections/NegationNonEmpty.scala
+++ b/src/main/scala/com/sksamuel/scapegoat/inspections/collections/NegationNonEmpty.scala
@@ -15,7 +15,7 @@ class NegationNonEmpty
def inspector(context: InspectionContext): Inspector =
new Inspector(context) {
- override def postTyperTraverser =
+ override def postTyperTraverser: context.Traverser =
new context.Traverser {
import context.global._
@@ -25,7 +25,7 @@ class NegationNonEmpty
override def inspect(tree: Tree): Unit = {
tree match {
- case Select(Select(lhs, IsEmpty), Bang) if isTraversable(lhs) =>
+ case Select(Select(lhs, IsEmpty), Bang) if isIterable(lhs) =>
context.warn(tree.pos, self, tree.toString.take(100))
case _ => continue(tree)
}
diff --git a/src/main/scala/com/sksamuel/scapegoat/inspections/collections/ReverseFunc.scala b/src/main/scala/com/sksamuel/scapegoat/inspections/collections/ReverseFunc.scala
index c7fa3990..8fbd2375 100644
--- a/src/main/scala/com/sksamuel/scapegoat/inspections/collections/ReverseFunc.scala
+++ b/src/main/scala/com/sksamuel/scapegoat/inspections/collections/ReverseFunc.scala
@@ -27,7 +27,7 @@ class ReverseFunc
def inspector(context: InspectionContext): Inspector =
new Inspector(context) {
- override def postTyperTraverser =
+ override def postTyperTraverser: context.Traverser =
new context.Traverser {
import context.global._
@@ -35,7 +35,7 @@ class ReverseFunc
override def inspect(tree: Tree): Unit = {
tree match {
case Select(Select(c, TermName("reverse")), TermName(FuncReplace(_, _)))
- if c.tpe <:< typeOf[Traversable[Any]] =>
+ if c.tpe <:< typeOf[Iterable[Any]] =>
context.warn(tree.pos, self, tree.toString.take(500))
case Select(
Apply(arrayOps1, List(Select(Apply(arrayOps2, List(_)), TermName("reverse")))),
diff --git a/src/main/scala/com/sksamuel/scapegoat/inspections/collections/ReverseTailReverse.scala b/src/main/scala/com/sksamuel/scapegoat/inspections/collections/ReverseTailReverse.scala
index fce57feb..07e2157a 100644
--- a/src/main/scala/com/sksamuel/scapegoat/inspections/collections/ReverseTailReverse.scala
+++ b/src/main/scala/com/sksamuel/scapegoat/inspections/collections/ReverseTailReverse.scala
@@ -12,7 +12,7 @@ class ReverseTailReverse
def inspector(context: InspectionContext): Inspector =
new Inspector(context) {
- override def postTyperTraverser =
+ override def postTyperTraverser: context.Traverser =
new context.Traverser {
import context.global._
@@ -20,7 +20,7 @@ class ReverseTailReverse
override def inspect(tree: Tree): Unit = {
tree match {
case Select(Select(Select(c, TermName("reverse")), TermName("tail")), TermName("reverse"))
- if isTraversable(c) =>
+ if isIterable(c) =>
context.warn(tree.pos, self, tree.toString.take(500))
case Select(
Apply(
diff --git a/src/main/scala/com/sksamuel/scapegoat/inspections/collections/ReverseTakeReverse.scala b/src/main/scala/com/sksamuel/scapegoat/inspections/collections/ReverseTakeReverse.scala
index af6c5568..d9a224eb 100644
--- a/src/main/scala/com/sksamuel/scapegoat/inspections/collections/ReverseTakeReverse.scala
+++ b/src/main/scala/com/sksamuel/scapegoat/inspections/collections/ReverseTakeReverse.scala
@@ -12,7 +12,7 @@ class ReverseTakeReverse
def inspector(context: InspectionContext): Inspector =
new Inspector(context) {
- override def postTyperTraverser =
+ override def postTyperTraverser: context.Traverser =
new context.Traverser {
import context.global._
@@ -22,7 +22,7 @@ class ReverseTakeReverse
case Select(
Apply(Select(Select(c, TermName("reverse")), TermName("take")), _),
TermName("reverse")
- ) if isTraversable(c) =>
+ ) if isIterable(c) =>
context.warn(tree.pos, self, tree.toString.take(500))
case Select(
Apply(
diff --git a/src/main/scala/com/sksamuel/scapegoat/inspections/collections/UnsafeTraversableMethods.scala b/src/main/scala/com/sksamuel/scapegoat/inspections/collections/UnsafeTraversableMethods.scala
index 6f6c9f6f..1c23391a 100644
--- a/src/main/scala/com/sksamuel/scapegoat/inspections/collections/UnsafeTraversableMethods.scala
+++ b/src/main/scala/com/sksamuel/scapegoat/inspections/collections/UnsafeTraversableMethods.scala
@@ -27,7 +27,7 @@ class UnsafeTraversableMethods
def inspector(context: InspectionContext): Inspector =
new Inspector(context) {
- override def postTyperTraverser =
+ override def postTyperTraverser: context.Traverser =
new context.Traverser {
import context.global._
@@ -35,7 +35,7 @@ class UnsafeTraversableMethods
override def inspect(tree: Tree): Unit = {
tree match {
case Select(left, TermName(method)) =>
- if (isTraversable(left) && unsafeMethods.contains(method))
+ if (isIterable(left) && unsafeMethods.contains(method))
context.warn(tree.pos, self, tree.toString.take(500))
case _ => continue(tree)
}
diff --git a/src/main/scala/com/sksamuel/scapegoat/inspections/math/UseLog10.scala b/src/main/scala/com/sksamuel/scapegoat/inspections/math/UseLog10.scala
index 84c80180..5c2aec06 100644
--- a/src/main/scala/com/sksamuel/scapegoat/inspections/math/UseLog10.scala
+++ b/src/main/scala/com/sksamuel/scapegoat/inspections/math/UseLog10.scala
@@ -12,7 +12,7 @@ class UseLog10
def inspector(context: InspectionContext): Inspector =
new Inspector(context) {
- override def postTyperTraverser =
+ override def postTyperTraverser: context.Traverser =
new context.Traverser {
import context.global._
diff --git a/src/main/scala/com/sksamuel/scapegoat/inspections/math/UseLog1P.scala b/src/main/scala/com/sksamuel/scapegoat/inspections/math/UseLog1P.scala
index c6589001..b833a454 100644
--- a/src/main/scala/com/sksamuel/scapegoat/inspections/math/UseLog1P.scala
+++ b/src/main/scala/com/sksamuel/scapegoat/inspections/math/UseLog1P.scala
@@ -12,12 +12,12 @@ class UseLog1P
def inspector(context: InspectionContext): Inspector =
new Inspector(context) {
- override def postTyperTraverser =
+ override def postTyperTraverser: context.Traverser =
new context.Traverser {
import context.global._
- def isMathPackage(pack: String) =
+ def isMathPackage(pack: String): Boolean =
pack == "scala.math.package" ||
pack == "java.lang.Math" ||
pack == "java.lang.StrictMath"
diff --git a/src/main/scala/com/sksamuel/scapegoat/inspections/math/UseSqrt.scala b/src/main/scala/com/sksamuel/scapegoat/inspections/math/UseSqrt.scala
index bc798406..d2c54158 100644
--- a/src/main/scala/com/sksamuel/scapegoat/inspections/math/UseSqrt.scala
+++ b/src/main/scala/com/sksamuel/scapegoat/inspections/math/UseSqrt.scala
@@ -13,7 +13,7 @@ class UseSqrt
def inspector(context: InspectionContext): Inspector =
new Inspector(context) {
- override def postTyperTraverser =
+ override def postTyperTraverser: context.Traverser =
new context.Traverser {
import context.global._
diff --git a/src/test/scala/com/sksamuel/scapegoat/FeedbackTest.scala b/src/test/scala/com/sksamuel/scapegoat/FeedbackTest.scala
index e9d10f01..4faf4ad3 100644
--- a/src/test/scala/com/sksamuel/scapegoat/FeedbackTest.scala
+++ b/src/test/scala/com/sksamuel/scapegoat/FeedbackTest.scala
@@ -10,7 +10,7 @@ import org.scalatest.{OneInstancePerTest, PrivateMethodTester}
/** @author Stephen Samuel */
class FeedbackTest extends AnyFreeSpec with Matchers with OneInstancePerTest with PrivateMethodTester {
- val position = NoPosition
+ val position: NoPosition.type = NoPosition
val defaultSourcePrefix = "src/main/scala/"
class DummyInspection(
@@ -32,7 +32,7 @@ class FeedbackTest extends AnyFreeSpec with Matchers with OneInstancePerTest wit
"This is explanation."
)
val reporter = new StoreReporter
- val feedback = new Feedback(reporter, testConfiguration(true, defaultSourcePrefix))
+ val feedback = new Feedback(reporter, testConfiguration(consoleOutput = true, defaultSourcePrefix))
feedback.warn(position, inspection)
reporter.infos should contain(
reporter.Info(
@@ -50,15 +50,14 @@ class FeedbackTest extends AnyFreeSpec with Matchers with OneInstancePerTest wit
"This is explanation."
)
val reporter = new StoreReporter
- val feedback = new Feedback(reporter, testConfiguration(true, defaultSourcePrefix))
+ val feedback = new Feedback(reporter, testConfiguration(consoleOutput = true, defaultSourcePrefix))
feedback.warn(position, inspection)
reporter.infos should contain(
- reporter
- .Info(
- position,
- "[scapegoat] [DummyInspection] My default is Warning\n This is explanation.",
- reporter.WARNING
- )
+ reporter.Info(
+ position,
+ "[scapegoat] [DummyInspection] My default is Warning\n This is explanation.",
+ reporter.WARNING
+ )
)
}
"for info" in {
@@ -69,7 +68,7 @@ class FeedbackTest extends AnyFreeSpec with Matchers with OneInstancePerTest wit
"This is explanation."
)
val reporter = new StoreReporter
- val feedback = new Feedback(reporter, testConfiguration(true, defaultSourcePrefix))
+ val feedback = new Feedback(reporter, testConfiguration(consoleOutput = true, defaultSourcePrefix))
feedback.warn(position, inspection)
reporter.infos should contain(
reporter.Info(
@@ -84,7 +83,7 @@ class FeedbackTest extends AnyFreeSpec with Matchers with OneInstancePerTest wit
"for `src/main/scala`" in {
val normalizeSourceFile = PrivateMethod[String](Symbol("normalizeSourceFile"))
val reporter = new StoreReporter
- val feedback = new Feedback(reporter, testConfiguration(true, defaultSourcePrefix))
+ val feedback = new Feedback(reporter, testConfiguration(consoleOutput = true, defaultSourcePrefix))
val source = "src/main/scala/com/sksamuel/scapegoat/Test.scala"
val result = feedback invokePrivate normalizeSourceFile(source)
result should ===("com.sksamuel.scapegoat.Test.scala")
@@ -93,7 +92,7 @@ class FeedbackTest extends AnyFreeSpec with Matchers with OneInstancePerTest wit
"for `app`" in {
val normalizeSourceFile = PrivateMethod[String](Symbol("normalizeSourceFile"))
val reporter = new StoreReporter
- val feedback = new Feedback(reporter, testConfiguration(true, "app/"))
+ val feedback = new Feedback(reporter, testConfiguration(consoleOutput = true, "app/"))
val source = "app/com/sksamuel/scapegoat/Test.scala"
val result = feedback invokePrivate normalizeSourceFile(source)
result should ===("com.sksamuel.scapegoat.Test.scala")
@@ -102,7 +101,7 @@ class FeedbackTest extends AnyFreeSpec with Matchers with OneInstancePerTest wit
"should add trailing / to the sourcePrefix automatically" in {
val normalizeSourceFile = PrivateMethod[String](Symbol("normalizeSourceFile"))
val reporter = new StoreReporter
- val feedback = new Feedback(reporter, testConfiguration(true, "app/custom"))
+ val feedback = new Feedback(reporter, testConfiguration(consoleOutput = true, "app/custom"))
val source = "app/custom/com/sksamuel/scapegoat/Test.scala"
val result = feedback invokePrivate normalizeSourceFile(source)
result should ===("com.sksamuel.scapegoat.Test.scala")
@@ -130,7 +129,8 @@ class FeedbackTest extends AnyFreeSpec with Matchers with OneInstancePerTest wit
)
val inspections = Seq(inspectionError, inspectionWarning, inspectionInfo)
val reporter = new StoreReporter
- val feedback = new Feedback(reporter, testConfiguration(true, defaultSourcePrefix, Levels.Info))
+ val feedback =
+ new Feedback(reporter, testConfiguration(consoleOutput = true, defaultSourcePrefix, Levels.Info))
inspections.foreach(inspection => feedback.warn(position, inspection))
feedback.warningsWithMinimalLevel.length should be(3)
}
@@ -156,7 +156,11 @@ class FeedbackTest extends AnyFreeSpec with Matchers with OneInstancePerTest wit
)
val inspections = Seq(inspectionError, inspectionWarning, inspectionInfo)
val reporter = new StoreReporter
- val feedback = new Feedback(reporter, testConfiguration(false, defaultSourcePrefix, Levels.Warning))
+ val feedback =
+ new Feedback(
+ reporter,
+ testConfiguration(consoleOutput = false, defaultSourcePrefix, Levels.Warning)
+ )
inspections.foreach(inspection => feedback.warn(position, inspection))
feedback.warningsWithMinimalLevel.length should be(2)
feedback.warningsWithMinimalLevel
@@ -184,7 +188,8 @@ class FeedbackTest extends AnyFreeSpec with Matchers with OneInstancePerTest wit
)
val inspections = Seq(inspectionError, inspectionWarning, inspectionInfo)
val reporter = new StoreReporter
- val feedback = new Feedback(reporter, testConfiguration(false, defaultSourcePrefix, Levels.Error))
+ val feedback =
+ new Feedback(reporter, testConfiguration(consoleOutput = false, defaultSourcePrefix, Levels.Error))
inspections.foreach(inspection => feedback.warn(position, inspection))
feedback.warningsWithMinimalLevel.length should be(1)
feedback.warningsWithMinimalLevel.map(_.level) should contain only (Seq(Levels.Error): _*)