From 39b2a20a5db15a46739f8a72420f6f5f68ab3899 Mon Sep 17 00:00:00 2001 From: Claudio Bley Date: Tue, 9 Jun 2020 17:35:51 +0200 Subject: [PATCH 1/6] Remove commons-io from libraryDependencies --- build.sbt | 1 - src/test/scala/com/sksamuel/scapegoat/PluginRunner.scala | 6 ++++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/build.sbt b/build.sbt index a1c78128..07134b3f 100644 --- a/build.sbt +++ b/build.sbt @@ -106,7 +106,6 @@ libraryDependencies ++= Seq( ExclusionRule(organization = "org.scala-lang") ), "org.scala-lang" % "scala-compiler" % scalaVersion.value % "test", - "commons-io" % "commons-io" % "2.7" % "test", "org.scalatest" %% "scalatest" % "3.2.0" % "test", "org.mockito" % "mockito-all" % "1.10.19" % "test", "joda-time" % "joda-time" % "2.10.6" % "test", diff --git a/src/test/scala/com/sksamuel/scapegoat/PluginRunner.scala b/src/test/scala/com/sksamuel/scapegoat/PluginRunner.scala index 2d0d1709..6904933d 100644 --- a/src/test/scala/com/sksamuel/scapegoat/PluginRunner.scala +++ b/src/test/scala/com/sksamuel/scapegoat/PluginRunner.scala @@ -3,6 +3,7 @@ package com.sksamuel.scapegoat import java.io.{File, FileNotFoundException} import java.net.URL import java.nio.charset.StandardCharsets +import java.nio.file.Files import scala.tools.nsc.reporters.ConsoleReporter @@ -33,8 +34,9 @@ trait PluginRunner { lazy val compiler = new ScapegoatCompiler(settings, inspections, reporter) def writeCodeSnippetToTempFile(code: String): File = { - val file = File.createTempFile("scapegoat_snippet", ".scala") - org.apache.commons.io.FileUtils.write(file, code, StandardCharsets.UTF_8) + val file = Files + .write(Files.createTempFile("scapegoat_snippet", ".scala"), code.getBytes(StandardCharsets.UTF_8)) + .toFile file.deleteOnExit() file } From e7ddc0208409571e154ee4d39696357a9b042cf9 Mon Sep 17 00:00:00 2001 From: Claudio Bley Date: Wed, 10 Jun 2020 07:53:59 +0200 Subject: [PATCH 2/6] Do not use symbol literals --- src/test/scala/com/sksamuel/scapegoat/FeedbackTest.scala | 6 +++--- .../inspections/FinalModifierOnCaseClassTest.scala | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/test/scala/com/sksamuel/scapegoat/FeedbackTest.scala b/src/test/scala/com/sksamuel/scapegoat/FeedbackTest.scala index e4ffc1f0..540e38a0 100644 --- a/src/test/scala/com/sksamuel/scapegoat/FeedbackTest.scala +++ b/src/test/scala/com/sksamuel/scapegoat/FeedbackTest.scala @@ -70,7 +70,7 @@ class FeedbackTest extends AnyFreeSpec with Matchers with OneInstancePerTest wit } "should use proper paths" - { "for `src/main/scala`" in { - val normalizeSourceFile = PrivateMethod[String]('normalizeSourceFile) + val normalizeSourceFile = PrivateMethod[String](Symbol("normalizeSourceFile")) val reporter = new StoreReporter val feedback = new Feedback(true, reporter, defaultSourcePrefix) val source = "src/main/scala/com/sksamuel/scapegoat/Test.scala" @@ -79,7 +79,7 @@ class FeedbackTest extends AnyFreeSpec with Matchers with OneInstancePerTest wit } "for `app`" in { - val normalizeSourceFile = PrivateMethod[String]('normalizeSourceFile) + val normalizeSourceFile = PrivateMethod[String](Symbol("normalizeSourceFile")) val reporter = new StoreReporter val feedback = new Feedback(true, reporter, "app/") val source = "app/com/sksamuel/scapegoat/Test.scala" @@ -88,7 +88,7 @@ class FeedbackTest extends AnyFreeSpec with Matchers with OneInstancePerTest wit } "should add trailing / to the sourcePrefix automatically" in { - val normalizeSourceFile = PrivateMethod[String]('normalizeSourceFile) + val normalizeSourceFile = PrivateMethod[String](Symbol("normalizeSourceFile")) val reporter = new StoreReporter val feedback = new Feedback(true, reporter, "app/custom") val source = "app/custom/com/sksamuel/scapegoat/Test.scala" diff --git a/src/test/scala/com/sksamuel/scapegoat/inspections/FinalModifierOnCaseClassTest.scala b/src/test/scala/com/sksamuel/scapegoat/inspections/FinalModifierOnCaseClassTest.scala index 6db0bebb..bfd52e2b 100644 --- a/src/test/scala/com/sksamuel/scapegoat/inspections/FinalModifierOnCaseClassTest.scala +++ b/src/test/scala/com/sksamuel/scapegoat/inspections/FinalModifierOnCaseClassTest.scala @@ -13,7 +13,7 @@ class FinalModifierOnCaseClassTest extends InspectionTest { private def assertNoFinalModOnCaseClass(code: String): Unit = { compileCodeSnippet(code) - compiler.scapegoat.feedback.warnings should be('empty) + compiler.scapegoat.feedback.warnings shouldBe empty } "Missing final modifier on case class" - { From 125581408d96108f019223684e79386576edd28c Mon Sep 17 00:00:00 2001 From: Claudio Bley Date: Wed, 10 Jun 2020 08:09:21 +0200 Subject: [PATCH 3/6] test: Fix typo --- src/test/scala/com/sksamuel/scapegoat/FeedbackTest.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/scala/com/sksamuel/scapegoat/FeedbackTest.scala b/src/test/scala/com/sksamuel/scapegoat/FeedbackTest.scala index 540e38a0..ec6556ef 100644 --- a/src/test/scala/com/sksamuel/scapegoat/FeedbackTest.scala +++ b/src/test/scala/com/sksamuel/scapegoat/FeedbackTest.scala @@ -96,7 +96,7 @@ class FeedbackTest extends AnyFreeSpec with Matchers with OneInstancePerTest wit result should ===("com.sksamuel.scapegoat.Test.scala") } } - "should use minimal wawrning level in reports" - { + "should use minimal warning level in reports" - { "for `info`" in { val inspectionError = new DummyInspection( "My default is Error", From b520a382c7883ce8d3b62f20c87f221962f99360 Mon Sep 17 00:00:00 2001 From: Claudio Bley Date: Fri, 26 Jun 2020 10:05:14 +0200 Subject: [PATCH 4/6] Fix scalafmt warnings ``` IndentOperator: top-level presets deprecated; use preset subsection DanglingParentheses: top-level presets deprecated; use preset subsection ``` --- .scalafmt.conf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.scalafmt.conf b/.scalafmt.conf index 9a885222..5412945c 100644 --- a/.scalafmt.conf +++ b/.scalafmt.conf @@ -14,12 +14,12 @@ align { {code = "=>", owner = "Case"} ] } -danglingParentheses = true +danglingParentheses.preset = true rewrite { rules = [PreferCurlyFors, RedundantBraces, RedundantParens, SortImports] redundantBraces.maxLines = 1 } -indentOperator = spray +indentOperator.preset = spray project { git = true excludeFilters = ["target"] From ddc2b501d5d548dae1eab5a9f08477bd223158b5 Mon Sep 17 00:00:00 2001 From: Claudio Bley Date: Fri, 26 Jun 2020 10:08:08 +0200 Subject: [PATCH 5/6] Cross build for Scala 2.13.3 * `-Xlint:nullary-override` is no longer accepted by scalac 2.13.3 (on by default) --- .github/workflows/pr-checks.yml | 1 + build.sbt | 11 +++++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/.github/workflows/pr-checks.yml b/.github/workflows/pr-checks.yml index 2b2efde6..7900fa6e 100644 --- a/.github/workflows/pr-checks.yml +++ b/.github/workflows/pr-checks.yml @@ -15,6 +15,7 @@ jobs: - 2.12.11 - 2.13.1 - 2.13.2 + - 2.13.3 steps: - uses: actions/checkout@v2 - uses: olafurpg/setup-scala@v7 diff --git a/build.sbt b/build.sbt index 07134b3f..28f1b712 100644 --- a/build.sbt +++ b/build.sbt @@ -22,8 +22,8 @@ developers := List( ) ) -scalaVersion := "2.13.2" -crossScalaVersions := Seq("2.11.12", "2.12.10", "2.12.11", "2.13.1", "2.13.2") +scalaVersion := "2.13.3" +crossScalaVersions := Seq("2.11.12", "2.12.10", "2.12.11", "2.13.1", "2.13.2", "2.13.3") autoScalaLibrary := false crossVersion := CrossVersion.full crossTarget := { @@ -38,7 +38,6 @@ val scalac13Options = Seq( "-Xlint:adapted-args", "-Xlint:inaccessible", "-Xlint:infer-any", - "-Xlint:nullary-override", "-Xlint:nullary-unit", "-Yrangepos", "-Ywarn-unused" @@ -76,7 +75,11 @@ scalacOptions := { common ++ (scalaBinaryVersion.value match { case "2.11" => scalac11Options case "2.12" => scalac12Options - case "2.13" => scalac13Options + 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] + }) }) } javacOptions ++= Seq("-source", "1.8", "-target", "1.8") From d4a3262c651c95ed893365f6e8c48add02260bbe Mon Sep 17 00:00:00 2001 From: Claudio Bley Date: Fri, 26 Jun 2020 10:13:29 +0200 Subject: [PATCH 6/6] Fix typo --- .../com/sksamuel/scapegoat/inspections/option/EitherGet.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/scala/com/sksamuel/scapegoat/inspections/option/EitherGet.scala b/src/main/scala/com/sksamuel/scapegoat/inspections/option/EitherGet.scala index e7117055..5475f4be 100644 --- a/src/main/scala/com/sksamuel/scapegoat/inspections/option/EitherGet.scala +++ b/src/main/scala/com/sksamuel/scapegoat/inspections/option/EitherGet.scala @@ -10,7 +10,7 @@ class EitherGet defaultLevel = Levels.Error, description = "Checks for use of .get on Left or Right projection.", explanation = - "Method .get on a Left and a Right projection in deprecated since 2.13, use Either.getOrElse or Either.swap.getOrElse instead." + "Method .get on a Left and a Right projection is deprecated since 2.13, use Either.getOrElse or Either.swap.getOrElse instead." ) { def inspector(context: InspectionContext): Inspector =