Skip to content

Update scalafmt-core to 3.8.6 #927

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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
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
3 changes: 3 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@ f6993516b833296bcd3bc9d93cb9b4b900bc888e

# Scala Steward: Reformat with scalafmt 3.7.4
4edf63a849a246160396ccf2f4da0bb2069006a2

# Scala Steward: Reformat with scalafmt 3.8.6
4934ae8bc324fdf40b29c87fb52b515c5fa294fd
2 changes: 1 addition & 1 deletion .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version = "3.8.3"
version = "3.8.6"
runner.dialect = scala3
maxColumn = 110
docstrings.style = Asterisk
Expand Down
6 changes: 2 additions & 4 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,8 @@ scalaVersion := "3.6.2"
crossScalaVersions := Seq("2.12.19", "2.12.20", "2.13.15", "2.13.16", "3.3.4", "3.6.2")
autoScalaLibrary := false
crossVersion := CrossVersion.full
crossTarget := {
// workaround for https://github.com/sbt/sbt/issues/5097
target.value / s"scala-${scalaVersion.value}"
}
// workaround for https://github.com/sbt/sbt/issues/5097
crossTarget := target.value / s"scala-${scalaVersion.value}"
versionScheme := Some("early-semver")
semanticdbEnabled := (scalaBinaryVersion.value == "3")
scalafixConfig := Some(file(if (scalaBinaryVersion.value == "3") ".scalafix.conf" else ".scalafix-2.conf"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ package com.sksamuel.scapegoat.inspections

import com.sksamuel.scapegoat.{Inspection, InspectionContext, Inspector, Levels}

class AvoidRequire extends
Inspection(
text = "Use of require",
defaultLevel = Levels.Warning,
description = "Use require in code.",
explanation = "Using require throws an untyped Exception."
) {
class AvoidRequire
extends Inspection(
text = "Use of require",
defaultLevel = Levels.Warning,
description = "Use require in code.",
explanation = "Using require throws an untyped Exception."
) {

def inspector(ctx: InspectionContext): Inspector =
new Inspector(ctx) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ package com.sksamuel.scapegoat.inspections.traits
import com.sksamuel.scapegoat._

class AbstractTrait
extends Inspection(
text = "Use of abstract trait",
defaultLevel = Levels.Info,
description = "Traits are automatically abstract.",
explanation = "The abstract modifier is used in class definitions. It is redundant for traits, and mandatory for all other classes which have incomplete members."
){
extends Inspection(
text = "Use of abstract trait",
defaultLevel = Levels.Info,
description = "Traits are automatically abstract.",
explanation =
"The abstract modifier is used in class definitions. It is redundant for traits, and mandatory for all other classes which have incomplete members."
) {

override def inspector(ctx: InspectionContext): Inspector = {
new Inspector(ctx) {
Expand All @@ -17,9 +18,8 @@ class AbstractTrait

import context.global._

def isAbstractTrait(positions: Map[Long, Position]): Boolean = {
def isAbstractTrait(positions: Map[Long, Position]): Boolean =
positions.contains(Flag.TRAIT) && positions.contains(Flag.ABSTRACT)
}

override def inspect(tree: Tree): Unit = {
tree match {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ class IsInstanceOf
tree match {
case TypeApply(Select(_, TermName("isInstanceOf")), _) =>
context.warn(tree.pos, self, tree.toString.take(500))
case DefDef(modifiers, _, _, _, _, _)
if modifiers.hasFlag(Flag.SYNTHETIC) => // avoid partial function stuff
case DefDef(modifiers, _, _, _, _, _) if modifiers.hasFlag(Flag.SYNTHETIC) => // avoid partial function stuff
case Match(_, cases) => // ignore selector and process cases
cases.foreach(traverse)
case _ => continue(tree)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,17 +55,14 @@ class ComparingUnrelatedTypesTest extends InspectionTest {
"compared to int literal" in verifyNoWarnings("""object A { val l = 100l; val b = l == 100 }""")
}
"for char" - {
"compared to char-sized long literal" in {
verifyNoWarnings("""object A { val c = 'a'; val l = c == 97L }""")
}
"compared to char-sized int literal" in {
verifyNoWarnings("""object A { val c = 'a'; val l = c == 97 }""")
}
"compared to char-sized long literal" in
verifyNoWarnings("""object A { val c = 'a'; val l = c == 97L }""")
"compared to char-sized int literal" in
verifyNoWarnings("""object A { val c = 'a'; val l = c == 97 }""")
}
"for short" - {
"compared to Short.MaxValue as int literal" in {
verifyNoWarnings("""object A { val s = 1.toShort; val b = s == 32767 }""")
}
"compared to Short.MaxValue as int literal" in
verifyNoWarnings("""object A { val s = 1.toShort; val b = s == 32767 }""")
}
"for double" - {
"compared to zero" in verifyNoWarnings("""object A { val d = 100d; val b = d == 0 }""")
Expand Down Expand Up @@ -113,9 +110,8 @@ class ComparingUnrelatedTypesTest extends InspectionTest {
|}""".stripMargin
)
}
"bound variable if guard" in {
verifyNoWarnings("""object A { System.getProperty("x") match { case s if s == "y" => } }""")
}
"bound variable if guard" in
verifyNoWarnings("""object A { System.getProperty("x") match { case s if s == "y" => } }""")
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,8 @@ class UnusedMethodParameterTest extends InspectionTest {
}

"should handle constructor params" - {
"ignore unused case class primary param" in {
assertNoWarnings("""case class Foo(x: Int)""")
}
"ignore unused case class primary param" in
assertNoWarnings("""case class Foo(x: Int)""")

"warn on unused case class secondary params" in {
val code = """case class Foo(x: Int)(y: Int)"""
Expand Down Expand Up @@ -196,9 +195,8 @@ class UnusedMethodParameterTest extends InspectionTest {
|}""".stripMargin)
}

"not warn on non-case class primary params marked val" in {
assertNoWarnings("""class Foo(val x: Int)""")
}
"not warn on non-case class primary params marked val" in
assertNoWarnings("""class Foo(val x: Int)""")
}
}

Expand Down
20 changes: 8 additions & 12 deletions src/test/scala/com/sksamuel/scapegoat/WarningTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,14 @@ class WarningTest extends AnyFreeSpec {

"Warning" - {
"hasMinimalLevelOf" - {
"info >= info" in {
assert(warning.hasMinimalLevelOf(Levels.Info) === true)
}
"info < warning" in {
assert(warning.hasMinimalLevelOf(Levels.Warning) === false)
}
"info < error" in {
assert(warning.hasMinimalLevelOf(Levels.Error) === false)
}
"error > warning" in {
assert(warning.copy(level = Levels.Error).hasMinimalLevelOf(Levels.Warning) === true)
}
"info >= info" in
assert(warning.hasMinimalLevelOf(Levels.Info) === true)
"info < warning" in
assert(warning.hasMinimalLevelOf(Levels.Warning) === false)
"info < error" in
assert(warning.hasMinimalLevelOf(Levels.Error) === false)
"error > warning" in
assert(warning.copy(level = Levels.Error).hasMinimalLevelOf(Levels.Warning) === true)
}
}

Expand Down