Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scala 2.13.3 #393

Merged
merged 6 commits into from
Jul 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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")
mccartney marked this conversation as resolved.
Show resolved Hide resolved
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