Skip to content

Commit

Permalink
Scala 2.13.3 (#393)
Browse files Browse the repository at this point in the history
* Remove commons-io from libraryDependencies

* Do not use symbol literals

* test: Fix typo

* Fix scalafmt warnings

```
IndentOperator: top-level presets deprecated; use preset subsection
DanglingParentheses: top-level presets deprecated; use preset subsection
```

* Cross build for Scala 2.13.3

* `-Xlint:nullary-override` is no longer accepted by scalac 2.13.3 (on by default)

* Fix typo
  • Loading branch information
avdv authored Jul 2, 2020
1 parent 1168ff8 commit 1a9089d
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 15 deletions.
1 change: 1 addition & 0 deletions .github/workflows/pr-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions .scalafmt.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
12 changes: 7 additions & 5 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -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 := {
Expand All @@ -38,7 +38,6 @@ val scalac13Options = Seq(
"-Xlint:adapted-args",
"-Xlint:inaccessible",
"-Xlint:infer-any",
"-Xlint:nullary-override",
"-Xlint:nullary-unit",
"-Yrangepos",
"-Ywarn-unused"
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -106,7 +109,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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down
8 changes: 4 additions & 4 deletions src/test/scala/com/sksamuel/scapegoat/FeedbackTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand All @@ -88,15 +88,15 @@ 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"
val result = feedback invokePrivate normalizeSourceFile(source)
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",
Expand Down
6 changes: 4 additions & 2 deletions src/test/scala/com/sksamuel/scapegoat/PluginRunner.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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" - {
Expand Down

0 comments on commit 1a9089d

Please sign in to comment.