Skip to content

Update scalafmt-core to 3.9.7 #564

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

Merged
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
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 @@ ff8ca52d610ca63ee0ab4fcfb5d79da13a1250b1

# Scala Steward: Reformat with scalafmt 3.8.6
c038644e07f224e668b7be8c53f9038cfd2275cf

# Scala Steward: Reformat with scalafmt 3.9.7
6140c78f063f429304c3195435068432de309492
2 changes: 1 addition & 1 deletion .scalafmt.conf
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ rewrite.rules = [RedundantBraces, RedundantParens, SortImports]
spaces.inImportCurlyBraces = true
indentOperator.preset = spray

version=3.9.6
version=3.9.7

4 changes: 2 additions & 2 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ lazy val commonSettings =
lazy val publishSettings = Seq(
licenses := Seq("MIT" -> url("https://opensource.org/licenses/MIT")),
homepage := Some(url("https://github.com/mockito/mockito-scala")),
scmInfo := Some(
scmInfo := Some(
ScmInfo(
url("https://github.com/mockito/mockito-scala"),
"[email protected]:mockito/mockito-scala.git"
Expand Down Expand Up @@ -123,7 +123,7 @@ lazy val cats = (project in file("cats"))
publishSettings,
libraryDependencies ++= Seq(
Dependencies.cats,
Dependencies.catsLaws % "test",
Dependencies.catsLaws % "test",
Dependencies.disciplineScalatest % "test",
Dependencies.scalatest % "test"
)
Expand Down
6 changes: 3 additions & 3 deletions common/src/main/scala/org/mockito/ReflectionUtils.scala
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ object ReflectionUtils {

implicit def symbolToMethodSymbol(sym: Symbol): Symbols#MethodSymbol = sym.asInstanceOf[Symbols#MethodSymbol]

private val mirror = runtimeMirror(getClass.getClassLoader)
private val mirror = runtimeMirror(getClass.getClassLoader)
private val customMirror = mirror.asInstanceOf[{
def methodToJava(sym: Symbols#MethodSymbol): Method
}]
Expand Down Expand Up @@ -130,7 +130,7 @@ object ReflectionUtils {
field.setAccessible(true)
val modifiersField: Field = uTry(clazz.getDeclaredField("modifiers")) match {
case Success(modifiers) => modifiers
case Failure(e) =>
case Failure(e) =>
uTry {
val getDeclaredFields0 = clazz.getDeclaredMethod("getDeclaredFields0", classOf[Boolean])
val accessibleBeforeSet: Boolean = getDeclaredFields0.isAccessible
Expand All @@ -142,7 +142,7 @@ object ReflectionUtils {
declaredFields.find("modifiers" == _.getName).get
} match {
case Success(modifiers) => modifiers
case Failure(ex) =>
case Failure(ex) =>
e.addSuppressed(ex)
throw e
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class ScalaMockHandler[T](mockSettings: MockCreationSettings[T], methodsToProces
i.callRealMethod()
else {
val rawArguments = i.getRawArguments
val arguments =
val arguments =
if (rawArguments != null && rawArguments.nonEmpty && !isCallRealMethod) unwrapArgs(method, rawArguments)
else rawArguments

Expand All @@ -42,18 +42,18 @@ class ScalaMockHandler[T](mockSettings: MockCreationSettings[T], methodsToProces
val transformed = methodsToProcess
.collectFirst {
case (mtd, indices) if method === mtd =>
val argumentMatcherStorage = mockingProgress().getArgumentMatcherStorage
val matchers = argumentMatcherStorage.pullLocalizedMatchers().asScala.toIterator
val matchersWereUsed = matchers.nonEmpty
def reportMatcher(): Unit = if (matchers.nonEmpty) argumentMatcherStorage.reportMatcher(matchers.next().getMatcher)
val argumentMatcherStorage = mockingProgress().getArgumentMatcherStorage
val matchers = argumentMatcherStorage.pullLocalizedMatchers().asScala.toIterator
val matchersWereUsed = matchers.nonEmpty
def reportMatcher(): Unit = if (matchers.nonEmpty) argumentMatcherStorage.reportMatcher(matchers.next().getMatcher)
def reportMatchers(varargs: Iterable[_]): Unit =
if (matchersWereUsed && varargs.nonEmpty) {
def reportAsEqTo(): Unit = varargs.map(EqTo(_)).foreach(argumentMatcherStorage.reportMatcher(_))
val matcher = matchers.next().getMatcher
matcher match {
case EqTo(value: Array[_]) if varargs.sameElements(value) => reportAsEqTo()
case EqTo(value) if varargs == value => reportAsEqTo()
case other =>
case other =>
argumentMatcherStorage.reportMatcher(other)
varargs.drop(1).foreach(_ => reportMatcher())
}
Expand Down Expand Up @@ -100,7 +100,7 @@ object ScalaMockHandler {
mockSettings
)

private val InvocationClassName = classOf[ScalaInvocation].getName
private val InvocationClassName = classOf[ScalaInvocation].getName
private def isCallRealMethod: Boolean =
(new Exception).getStackTrace.toList.exists { t =>
t.getClassName == InvocationClassName &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class ScalaInvocation(
override def isVerified: Boolean = verified || isIgnoredForVerification
override def getMock: AnyRef = mockRef.get
override def getMethod: Method = mockitoMethod.getJavaMethod
override def callRealMethod(): AnyRef =
override def callRealMethod(): AnyRef =
if (realMethod.isInvokable) realMethod.invoke
else throw cannotCallAbstractRealMethod

Expand All @@ -62,7 +62,7 @@ class ScalaInvocation(
val state = Seq(super.hashCode(), getMock, mockitoMethod, arguments.toSeq)
state.map(_.hashCode()).foldLeft(0)((a, b) => 31 * a + b)
}
override def toString: String = new PrintSettings().print(getArgumentsAsMatchers, this)
override def toString: String = new PrintSettings().print(getArgumentsAsMatchers, this)
override def getArgumentsAsMatchers: util.List[ArgumentMatcher[_]] =
arguments.map(EqTo(_)(serialisableEquality[AnyRef], ValueClassExtractor.instance[AnyRef], $pt): ArgumentMatcher[_]).toList.asJava
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ abstract class ScalaBaseStubbing[T: ValueClassExtractor] {

protected def _thenCallRealMethod(): ScalaOngoingStubbing[T] = delegate.thenCallRealMethod()

protected def _thenAnswer(f: => T): ScalaOngoingStubbing[T] = delegate thenAnswer invocationToAnswer(_ => f)
protected def _thenAnswer(f: => T): ScalaOngoingStubbing[T] = delegate thenAnswer invocationToAnswer(_ => f)
protected def _thenAnswer[P0: ClassTag: ValueClassWrapper](f: P0 => T): ScalaOngoingStubbing[T] =
clazz[P0] match {
case c if c == classOf[InvocationOnMock] => delegate thenAnswer invocationToAnswer(i => f(i.asInstanceOf[P0]))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ case class ScalaFirstStubbing[T: ValueClassExtractor](delegate: OngoingStubbing[
}
}

def thenAnswer(f: => T): ScalaOngoingStubbing[T] = _thenAnswer(f)
def thenAnswer(f: => T): ScalaOngoingStubbing[T] = _thenAnswer(f)
def thenAnswer[P0: ValueClassWrapper](f: P0 => T)(implicit classTag: ClassTag[P0] = defaultClassTag[P0]): ScalaOngoingStubbing[T] =
_thenAnswer(f)
def thenAnswer[P0: ValueClassWrapper, P1: ValueClassWrapper](f: (P0, P1) => T): ScalaOngoingStubbing[T] =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ case class ScalaOngoingStubbing[T: ValueClassExtractor](delegate: OngoingStubbin
*/
def andThenCallRealMethod(): ScalaOngoingStubbing[T] = _thenCallRealMethod()

def andThenAnswer(f: => T): ScalaOngoingStubbing[T] = _thenAnswer(f)
def andThenAnswer(f: => T): ScalaOngoingStubbing[T] = _thenAnswer(f)
def andThenAnswer[P0: ValueClassWrapper](f: P0 => T)(implicit classTag: ClassTag[P0] = defaultClassTag[P0]): ScalaOngoingStubbing[T] =
_thenAnswer(f)
def andThenAnswer[P0: ValueClassWrapper, P1: ValueClassWrapper](f: (P0, P1) => T): ScalaOngoingStubbing[T] =
Expand Down
8 changes: 4 additions & 4 deletions core/src/main/scala/org/mockito/IdiomaticMockitoBase.scala
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ object IdiomaticMockitoBase {

case class Times(times: Int) extends ScalaVerificationMode {
override def verificationMode: VerificationMode = Mockito.times(times)
def within(d: Duration): ScalaVerificationMode =
def within(d: Duration): ScalaVerificationMode =
new ScalaVerificationMode {
override def verificationMode: VerificationMode = Mockito.timeout(d.toMillis).times(times)
}
Expand All @@ -53,7 +53,7 @@ object IdiomaticMockitoBase {

case class AtLeast(times: Int) extends ScalaVerificationMode {
override def verificationMode: VerificationMode = Mockito.atLeast(times)
def within(d: Duration): ScalaVerificationMode =
def within(d: Duration): ScalaVerificationMode =
new ScalaVerificationMode {
override def verificationMode: VerificationMode = Mockito.timeout(d.toMillis).atLeast(times)
}
Expand All @@ -65,15 +65,15 @@ object IdiomaticMockitoBase {

case class AtMost(times: Int) extends ScalaVerificationMode {
override def verificationMode: VerificationMode = Mockito.atMost(times)
def after(d: Duration): ScalaVerificationMode =
def after(d: Duration): ScalaVerificationMode =
new ScalaVerificationMode {
override def verificationMode: VerificationMode = Mockito.after(d.toMillis).atMost(times)
}
}

object OnlyOn extends ScalaVerificationMode {
override def verificationMode: VerificationMode = Mockito.only
def within(d: Duration): ScalaVerificationMode =
def within(d: Duration): ScalaVerificationMode =
new ScalaVerificationMode {
override def verificationMode: VerificationMode = Mockito.timeout(d.toMillis).only
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class NormalClassExtractor[T] extends ValueClassExtractor[T] {
class ReflectionExtractor[VC] extends ValueClassExtractor[VC] {
override def extract(vc: VC): Any = {
val constructorParam = vc.getClass.getConstructors.head.getParameters.head
val accessor = vc.getClass.getMethods
val accessor = vc.getClass.getMethods
.filter(m => m.getName == constructorParam.getName || m.getName.endsWith("$$" + constructorParam.getName))
.head
accessor.setAccessible(true)
Expand Down
4 changes: 2 additions & 2 deletions macro/src/main/scala/org/mockito/DoSomethingMacro.scala
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ object DoSomethingMacro {
if (pf.isDefinedAt(invocation))
pf(invocation)
else if (pf.isDefinedAt(invocation.children.last)) {
val vals = invocation.children.dropRight(1)
val vals = invocation.children.dropRight(1)
val valsByName = vals.collect { case line @ q"$_ val $name:$_ = $value" =>
name.toString -> (value.asInstanceOf[c.Tree], line)
}.toMap
Expand All @@ -203,7 +203,7 @@ object DoSomethingMacro {
q"$action.when($obj).$method[..$targs](...$newArgs)"
}

val call = show(inlinedArgsCall)
val call = show(inlinedArgsCall)
val usedVals = valsByName.collect {
case (name, (_, line)) if call.contains(name) => line
}
Expand Down
2 changes: 1 addition & 1 deletion macro/src/main/scala/org/mockito/Specs2VerifyMacro.scala
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ object Specs2VerifyMacro extends VerificationMacroTransformer {

case q"$_.got[$_]({..$block})($order)" =>
block.foldLeft(q"") {
case (q"", t) => if (transformSpecs2Verification.isDefinedAt(t)) transformSpecs2Verification(t) else q"$t"
case (q"", t) => if (transformSpecs2Verification.isDefinedAt(t)) transformSpecs2Verification(t) else q"$t"
case (other, t) =>
if (transformSpecs2Verification.isDefinedAt(t)) q"$other and ${transformSpecs2Verification(t)}" else q"$other and $t"
}
Expand Down
8 changes: 4 additions & 4 deletions macro/src/main/scala/org/mockito/VerifyMacro.scala
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ private[mockito] trait VerificationMacroTransformer {
if (pf.isDefinedAt(invocation))
pf(invocation)
else if (invocation.children.nonEmpty && pf.isDefinedAt(invocation.children.last)) {
val vals = invocation.children.dropRight(1)
val vals = invocation.children.dropRight(1)
val valsByName = vals.collect { case line @ q"$_ val $name:$_ = $value" =>
name.toString -> (value.asInstanceOf[c.Tree], line)
}.toMap
Expand All @@ -78,7 +78,7 @@ private[mockito] trait VerificationMacroTransformer {
q"verification($order.verifyWithMode($obj, $times).$method[..$targs](...$newArgs))"
}

val call = show(inlinedArgsCall)
val call = show(inlinedArgsCall)
val usedVals = valsByName.collect {
case (name, (_, line)) if call.contains(name) => line
}
Expand All @@ -92,8 +92,8 @@ private[mockito] trait VerificationMacroTransformer {

def transformMockWasNeverCalled(obj: c.Tree, called: c.Tree): c.Tree =
called match {
case q"$_.called" => q"verification(_root_.org.mockito.MockitoSugar.verifyZeroInteractions($obj))"
case q"$_.calledAgain" => q"verification(_root_.org.mockito.MockitoSugar.verifyNoMoreInteractions($obj))"
case q"$_.called" => q"verification(_root_.org.mockito.MockitoSugar.verifyZeroInteractions($obj))"
case q"$_.calledAgain" => q"verification(_root_.org.mockito.MockitoSugar.verifyNoMoreInteractions($obj))"
case q"$_.calledAgain.apply($_.ignoringStubs)" =>
q"verification(_root_.org.mockito.MockitoSugar.verifyNoMoreInteractions(_root_.org.mockito.MockitoSugar.ignoreStubs($obj): _*))"
}
Expand Down
26 changes: 13 additions & 13 deletions macro/src/main/scala/org/mockito/WhenMacro.scala
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ object WhenMacro {
if (pf.isDefinedAt(invocation))
pf(invocation)
else if (pf.isDefinedAt(invocation.children.last)) {
val vals = invocation.children.dropRight(1)
val vals = invocation.children.dropRight(1)
val valsByName = vals.collect { case line @ q"$_ val $name:$_ = $value" =>
name.toString -> (value.asInstanceOf[c.Tree], line)
}.toMap
Expand All @@ -38,7 +38,7 @@ object WhenMacro {
q"$obj.$method[..$targs](...$newArgs)"
}

val call = show(inlinedArgsCall)
val call = show(inlinedArgsCall)
val usedVals = valsByName.collect {
case (name, (_, line)) if call.contains(name) => line
}
Expand All @@ -47,9 +47,9 @@ object WhenMacro {
} else throw new Exception(s"Couldn't recognize invocation ${show(invocation)}")
}

private val ShouldReturnOptions = Set("shouldReturn", "mustReturn", "returns")
private val FunctionalShouldReturnOptions = ShouldReturnOptions.map(_ + "F")
private val FunctionalShouldReturnOptions2 = ShouldReturnOptions.map(_ + "FG")
private val ShouldReturnOptions = Set("shouldReturn", "mustReturn", "returns")
private val FunctionalShouldReturnOptions = ShouldReturnOptions.map(_ + "F")
private val FunctionalShouldReturnOptions2 = ShouldReturnOptions.map(_ + "FG")
def shouldReturn[T: c.WeakTypeTag](c: blackbox.Context): c.Tree = {
import c.universe._

Expand Down Expand Up @@ -88,7 +88,7 @@ object WhenMacro {
def willBe(called: Called.type): Called.type = called
}

val ShouldCallOptions = Set("shouldCall", "mustCall", "calls")
val ShouldCallOptions = Set("shouldCall", "mustCall", "calls")
def shouldCallRealMethod[T: c.WeakTypeTag](c: blackbox.Context)(crm: c.Expr[RealMethod.type]): c.Expr[ScalaOngoingStubbing[T]] = {
import c.universe._

Expand All @@ -104,9 +104,9 @@ object WhenMacro {
r
}

private val ShouldThrowOptions = Set("shouldThrow", "mustThrow", "throws")
private val FunctionalShouldFailOptions = Set("shouldFailWith", "mustFailWith", "failsWith", "raises")
private val FunctionalShouldFailOptions2 = Set("shouldFailWithG", "mustFailWithG", "failsWithG", "raisesG")
private val ShouldThrowOptions = Set("shouldThrow", "mustThrow", "throws")
private val FunctionalShouldFailOptions = Set("shouldFailWith", "mustFailWith", "failsWith", "raises")
private val FunctionalShouldFailOptions2 = Set("shouldFailWithG", "mustFailWithG", "failsWithG", "raisesG")
def shouldThrow[T: c.WeakTypeTag](c: blackbox.Context): c.Tree = {
import c.universe._

Expand Down Expand Up @@ -450,9 +450,9 @@ object WhenMacro {
// }
}

private val ShouldAnswerOptions = Set("shouldAnswer", "mustAnswer", "answers")
private val FunctionalShouldAnswerOptions = ShouldAnswerOptions.map(_ + "F")
private val FunctionalShouldAnswerOptions2 = ShouldAnswerOptions.map(_ + "FG")
private val ShouldAnswerOptions = Set("shouldAnswer", "mustAnswer", "answers")
private val FunctionalShouldAnswerOptions = ShouldAnswerOptions.map(_ + "F")
private val FunctionalShouldAnswerOptions2 = ShouldAnswerOptions.map(_ + "FG")
def shouldAnswer[T: c.WeakTypeTag](c: blackbox.Context): c.Tree = {
import c.universe._

Expand All @@ -476,7 +476,7 @@ object WhenMacro {
def apply(pf: PartialFunction[Any, T]): ScalaOngoingStubbing[T] = os thenAnswer pf
}

private val ShouldAnswerPFOptions = Set("shouldAnswerPF", "mustAnswerPF", "answersPF")
private val ShouldAnswerPFOptions = Set("shouldAnswerPF", "mustAnswerPF", "answersPF")
def shouldAnswerPF[T: c.WeakTypeTag](c: blackbox.Context): c.Tree = {
import c.universe._

Expand Down
4 changes: 2 additions & 2 deletions project/Dependencies.scala
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ object Dependencies {
}
)

val cats = "org.typelevel" %% "cats-core" % "2.13.0" % "provided"
val scalaz = "org.scalaz" %% "scalaz-core" % "7.3.8" % "provided"
val cats = "org.typelevel" %% "cats-core" % "2.13.0" % "provided"
val scalaz = "org.scalaz" %% "scalaz-core" % "7.3.8" % "provided"

val catsLaws = "org.typelevel" %% "cats-laws" % "2.13.0"

Expand Down
2 changes: 1 addition & 1 deletion scalatest/src/test/scala/user/org/mockito/Issue251.scala
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class Issue251 extends AnyFlatSpec with IdiomaticMockito with Matchers with Argu
cars += (0 -> Car(0))

def getCar(id: Int): Option[Car] = cars.get(id)
def saveCar(car: Car) = {
def saveCar(car: Car) = {
cars += car.id -> car;
car
}
Expand Down
Loading