Skip to content

Commit

Permalink
style: upgrade scalafmt
Browse files Browse the repository at this point in the history
  • Loading branch information
etorreborre committed Jan 15, 2025
1 parent 26201b6 commit 3b3dfc4
Show file tree
Hide file tree
Showing 12 changed files with 57 additions and 27 deletions.
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.4"
runner.dialect = scala3

maxColumn = 120
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,8 @@ case class Property[T](value: () => Option[T], evaluated: Boolean = false, evalu
def map[U](f: T => U)(using CanEqual[U, U]): Property[U] = new Property(() => optionalValue.map(f))

/** option-like orElse */
def orElse[U >: T](other: =>Property[U])(using CanEqual[U, U]): Property[U] = new Property(() =>
optionalValue.orElse(other.optionalValue)
)
def orElse[U >: T](other: =>Property[U])(using CanEqual[U, U]): Property[U] =
new Property(() => optionalValue.orElse(other.optionalValue))

/** option-like toLeft */
def toLeft[R](right: R): Either[T, R] = optionalValue.toLeft(right)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,7 @@ object Snippet:
* 3 things need to be trimmed:
*
* - the "snippet" method call
*
* - the expression from start and end accolades if it is a multiline expression
*
* - in some case it is necessary to add a dummy expression so that the range position of the captured snippet is
* correct. /**/;1/**/ is the smallest such expression
*/
Expand Down
7 changes: 4 additions & 3 deletions common/shared/src/main/scala/org/specs2/main/Diffs.scala
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,10 @@ case class SmartDiffs(

/** @return the diffs for sequences */
def showSeqDiffs(actual: Seq[Any], expected: Seq[Any], ordered: Boolean): (Seq[String], Seq[String]) =
val (matched, missing) = BestMatching.findBestMatch(actual, expected, (t: Any, v: Any) => v == t, eachCheck = true)(
using AsResult.booleanAsResult
)
val (matched, missing) =
BestMatching.findBestMatch(actual, expected, (t: Any, v: Any) => v == t, eachCheck = true)(using
AsResult.booleanAsResult
)
val (_, koValues) = matched.partition(_._3.isSuccess)
val added = koValues.map(_._1)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ trait AnsiColors:

/** @return a string with no color codes */
def removeColors(s: String, doIt: Boolean = true): String =
if doIt then all.foldLeft(s.notNull) { (res, cur) => res.replace(cur.color, "") }
else s.notNull
if doIt then all.foldLeft(s.notNull) { (res, cur) => res.replace(cur.color, "") } else s.notNull

/** @return
* a colored string (if args.color == true) color markers are inserted at the beginning and end of each line so
Expand Down
39 changes: 33 additions & 6 deletions common/shared/src/main/scala/org/specs2/text/ShowText.scala
Original file line number Diff line number Diff line change
Expand Up @@ -328,8 +328,16 @@ open case class Show8[T1, T2, T3, T4, T5, T6, T7, T8](
def show10[T9, T10](show10: T10 => String): Show10[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10] =
Show10(show1, show2, show3, show4, show5, show6, show7, show8, (_: T9).notNull, show10)

def show(t1: T1, t2: T2, t3: T3, t4: T4, t5: T5, t6: T6, t7: T7, t8: T8)
: (String, String, String, String, String, String, String, String) =
def show(
t1: T1,
t2: T2,
t3: T3,
t4: T4,
t5: T5,
t6: T6,
t7: T7,
t8: T8
): (String, String, String, String, String, String, String, String) =
(show1(t1), show2(t2), show3(t3), show4(t4), show5(t5), show6(t6), show7(t7), show8(t8))

def showList(t1: T1, t2: T2, t3: T3, t4: T4, t5: T5, t6: T6, t7: T7, t8: T8): List[String] =
Expand All @@ -349,8 +357,17 @@ open case class Show9[T1, T2, T3, T4, T5, T6, T7, T8, T9](
def show10[T10](show10: T10 => String): Show10[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10] =
Show10(show1, show2, show3, show4, show5, show6, show7, show8, show9, show10)

def show(t1: T1, t2: T2, t3: T3, t4: T4, t5: T5, t6: T6, t7: T7, t8: T8, t9: T9)
: (String, String, String, String, String, String, String, String, String) =
def show(
t1: T1,
t2: T2,
t3: T3,
t4: T4,
t5: T5,
t6: T6,
t7: T7,
t8: T8,
t9: T9
): (String, String, String, String, String, String, String, String, String) =
(show1(t1), show2(t2), show3(t3), show4(t4), show5(t5), show6(t6), show7(t7), show8(t8), show9(t9))

def showList(t1: T1, t2: T2, t3: T3, t4: T4, t5: T5, t6: T6, t7: T7, t8: T8, t9: T9): List[String] =
Expand All @@ -369,8 +386,18 @@ case class Show10[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10](
show10: T10 => String = (_: T10).notNull
):

def show(t1: T1, t2: T2, t3: T3, t4: T4, t5: T5, t6: T6, t7: T7, t8: T8, t9: T9, t10: T10)
: (String, String, String, String, String, String, String, String, String, String) =
def show(
t1: T1,
t2: T2,
t3: T3,
t4: T4,
t5: T5,
t6: T6,
t7: T7,
t8: T8,
t9: T9,
t10: T10
): (String, String, String, String, String, String, String, String, String, String) =
(show1(t1), show2(t2), show3(t3), show4(t4), show5(t5), show6(t6), show7(t7), show8(t8), show9(t9), show10(t10))

def showList(t1: T1, t2: T2, t3: T3, t4: T4, t5: T5, t6: T6, t7: T7, t8: T8, t9: T9, t10: T10): List[String] =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ object S2StringContext:
*
* 1. if there is a piece of text on 1 line then the text is the execution description
*
* 2. if there is some text on more than one line then
* 2. if there is some text on more than one line then
*
* 2.1 if the last line contains only spaces (followed by the execution line) then this is an auto-example which uses
* its own 'sourceCode' as a Description
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,7 @@ case class SteppedExecutor(env: Env) extends Executor:
*
* - "join" points are respected, i.e. when a Fragment is a join we must make sure that all previously executing
* fragments have finished their execution
*
* - the fragments execute sequentially when args.sequential is true
*
* - the execution stops if one fragment indicates that the result of the previous executions is not correct
*/
private def sequencedExecution(specArguments: Arguments): AsyncTransducer[Fragment, Fragment] = {
Expand Down
6 changes: 4 additions & 2 deletions html/src/main/scala/org/specs2/reporter/HtmlBodyPrinter.scala
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,8 @@ trait HtmlBodyPrinter:
<message class="info">{r.message}</message>
</li>

if level.incrementNext then <ul>{example}</ul>
if level.incrementNext then
<ul>{example}</ul>
else example

case f if Fragment.isStepOrAction(f) =>
Expand Down Expand Up @@ -218,7 +219,8 @@ trait HtmlBodyPrinter:
case _ => NodeSeq.Empty

val fullMessage =
if showTrace then <li class ="failure toggle" onclick={toggleElement(f)}>{message}{detailedFailure}</li>
if showTrace then
<li class ="failure toggle" onclick={toggleElement(f)}>{message}{detailedFailure}</li>
else <li class ="failure notoggle">{message}{detailedFailure}</li>

val trace =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import scala.annotation.*
* Implementation notes:
* - the parameter to the apply method must be a by-name parameter. This allows some values to be evaluated only when
* necessary.
*
* - However in the implementation of the apply function, it must be taken care of not evaluating the parameter
* twice. Assigning it to a val is the solution to this issue.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -610,8 +610,7 @@ case class ContainWithResultSeq[T](
else
failures
.map { case (value, rs) => "- " + value + "\n" + rs.map(" * " + _).mkString("\n") }
.mkString("\n", "\n", "\n")
)
.mkString("\n", "\n", "\n"))
)

val r =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1172,8 +1172,16 @@ case class ScalaCheckFunction8[T1, T2, T3, T4, T5, T6, T7, T8, R](
def setGen6(g6: Gen[T6]): SelfType = setArbitrary6(Arbitrary(g6))
def setGen7(g7: Gen[T7]): SelfType = setArbitrary7(Arbitrary(g7))
def setGen8(g8: Gen[T8]): SelfType = setArbitrary8(Arbitrary(g8))
def setGens(g1: Gen[T1], g2: Gen[T2], g3: Gen[T3], g4: Gen[T4], g5: Gen[T5], g6: Gen[T6], g7: Gen[T7], g8: Gen[T8])
: SelfType =
def setGens(
g1: Gen[T1],
g2: Gen[T2],
g3: Gen[T3],
g4: Gen[T4],
g5: Gen[T5],
g6: Gen[T6],
g7: Gen[T7],
g8: Gen[T8]
): SelfType =
setGen1(g1).setGen2(g2).setGen3(g3).setGen4(g4).setGen5(g5).setGen6(g6).setGen7(g7).setGen8(g8)

def setShrink1(s1: Shrink[T1]): SelfType = copy(argInstances1 = argInstances1.copy(shrink = Some(s1)))
Expand Down

0 comments on commit 3b3dfc4

Please sign in to comment.