Skip to content
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 .scalafix.conf
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ rules = [
OrganizeImports {
coalesceToWildcardImportThreshold = 3
groupedImports = AggressiveMerge
targetDialect = Scala3

removeUnused = false
}
4 changes: 3 additions & 1 deletion .scalafmt.conf
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@ spaces.inImportCurlyBraces = true
rewrite.rules = [
AvoidInfix,
RedundantParens,
AsciiSortImports,
Imports,
PreferCurlyFors
]
rewrite.imports.sort = ascii
newlines.afterCurlyLambda = preserve
newlines.beforeCurlyLambdaParams = multilineWithCaseOnly
project.includePaths."+" = ["glob:**.md"]
rewrite.scala3.convertToNewSyntax = true
14 changes: 7 additions & 7 deletions ducktape/src/main/scala/io/github/arainko/ducktape/Mode.scala
Original file line number Diff line number Diff line change
Expand Up @@ -65,18 +65,18 @@ object Mode {
transformation(elem) match {
case Left(errors) =>
accumulatedErrors.addAll(errors)
if (isErroredOut == false) {
if isErroredOut == false then {
isErroredOut = true
accumulatedSuccesses.clear()
}
case Right(value) =>
if (isErroredOut == false) {
if isErroredOut == false then {
accumulatedSuccesses.addOne(value)
}
}
}

if (isErroredOut) Left(accumulatedErrors.result()) else Right(accumulatedSuccesses.result())
if isErroredOut then Left(accumulatedErrors.result()) else Right(accumulatedSuccesses.result())
}
}

Expand Down Expand Up @@ -107,7 +107,7 @@ object Mode {

val resultBuilder = factory.newBuilder
val iterator = collection.iterator
while (iterator.hasNext && !isErroredOut) {
while iterator.hasNext && !isErroredOut do {
transformation(iterator.next()) match {
case err @ Left(_) =>
error = err.asInstanceOf[Left[E, Nothing]]
Expand All @@ -117,7 +117,7 @@ object Mode {
}
}

if (isErroredOut) error else Right(resultBuilder.result())
if isErroredOut then error else Right(resultBuilder.result())
}

}
Expand All @@ -137,7 +137,7 @@ object Mode {
var isErroredOut = false
val resultBuilder = factory.newBuilder
val iterator = collection.iterator
while (iterator.hasNext && !isErroredOut) {
while iterator.hasNext && !isErroredOut do {
transformation(iterator.next()) match {
case None =>
isErroredOut = true
Expand All @@ -147,7 +147,7 @@ object Mode {
}
}

if (isErroredOut) None else Some(resultBuilder.result())
if isErroredOut then None else Some(resultBuilder.result())
}

}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package io.github.arainko.ducktape

import io.github.arainko.ducktape
import io.github.arainko.ducktape.Transformer.Fallible
import io.github.arainko.ducktape.*
import io.github.arainko.ducktape.Transformer.Fallible

package fallible {
@deprecated(message = "Use io.github.arainko.ducktape.Transformer.Fallible instead", since = "ducktape 0.2.0-M3")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ private[ducktape] object Constructor {
}

// workaround for invoking constructors of singleton which in turn actually create new instances of singletons!
if (tpe.typeSymbol.flags.is(Flags.Module)) report.errorAndAbort("Cannot invoke constructor of a singleton")
if tpe.typeSymbol.flags.is(Flags.Module) then report.errorAndAbort("Cannot invoke constructor of a singleton")

New(Inferred(repr))
.select(constructor)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ private[ducktape] object Debug extends LowPriorityDebug {
case Empty => ""
case Text(value) => value
case p @ Product(name, fields) =>
if (p.length >= 80) {
if p.length >= 80 then {
s"$name(".bold + Separator +
fields.map { (name, ast) =>
ident(depth + 1) + name.yellow + " = ".yellow + recurse(ast, depth + 1)
Expand All @@ -180,7 +180,7 @@ private[ducktape] object Debug extends LowPriorityDebug {
}

case c @ Collection(name, values) =>
if (c.length >= 80) {
if c.length >= 80 then {
s"$name(".bold + Separator +
values.map(value => ident(depth + 1) + recurse(value, depth + 1)).mkString("," + Separator) + Separator + ident(
depth
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ private[ducktape] object Logger {
.getOrElse("")
val formatted = s"${green(s"[${level.toString().toUpperCase()}]")}$location $msg"
this match {
case StdOut => if (filter(msg, location)) println(formatted)
case Report => if (filter(msg, location)) quotes.reflect.report.info(formatted)
case StdOut => if filter(msg, location) then println(formatted)
case Report => if filter(msg, location) then quotes.reflect.report.info(formatted)
}
}
}
Expand All @@ -48,8 +48,8 @@ private[ducktape] object Logger {

inline def info(inline msg: String)(using quotes: Quotes): Unit =
inline level match {
case Level.Debug => if (level <= Level.Info) output.print(msg, Level.Info)
case Level.Info => if (level <= Level.Info) output.print(msg, Level.Info)
case Level.Debug => if level <= Level.Info then output.print(msg, Level.Info)
case Level.Info => if level <= Level.Info then output.print(msg, Level.Info)
case Level.Off => ()
}

Expand All @@ -68,8 +68,8 @@ private[ducktape] object Logger {

inline def debug(inline msg: String)(using quotes: Quotes): Unit =
inline level match {
case Level.Debug => if (level <= Level.Debug) output.print(msg, Level.Debug)
case Level.Info => if (level <= Level.Debug) output.print(msg, Level.Debug)
case Level.Debug => if level <= Level.Debug then output.print(msg, Level.Debug)
case Level.Info => if level <= Level.Debug then output.print(msg, Level.Debug)
case Level.Off => ()
}

Expand All @@ -85,7 +85,7 @@ extension (ctx: StringContext) {
val pi = ctx.parts.iterator
val ai = args.iterator
val bldr = new StringBuilder(pi.next())
while (ai.hasNext) {
while ai.hasNext do {
bldr.append(ai.next().getClass().getSimpleName())
bldr.append(pi.next())
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package io.github.arainko.ducktape.internal

import io.github.arainko.ducktape.internal.*
import io.github.arainko.ducktape.internal.Debug.AST
import io.github.arainko.ducktape.internal.Path.Segment
import io.github.arainko.ducktape.internal.*

import scala.quoted.*
import scala.reflect.TypeTest
Expand Down Expand Up @@ -57,15 +57,15 @@ private[ducktape] final case class Path(root: Type[?], segments: Vector[Path.Seg

val printedRoot = root.repr.widen.show(using Printer.TypeReprShortCode)

if (self.segments.isEmpty) printedRoot
if self.segments.isEmpty then printedRoot
else
self.segments.map {
case Path.Segment.Field(_, name) => name
case Segment.TupleElement(_, index) => s"apply($index)"
case Path.Segment.Element(_) => "element"
case Path.Segment.Case(tpe) =>
val repr = tpe.repr
val suffix = if (repr.isSingleton) ".type" else ""
val suffix = if repr.isSingleton then ".type" else ""
s"at[${tpe.repr.show(using Printer.TypeReprAnsiCode)}${suffix}]"
}.mkString(s"$printedRoot.", ".", "")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ private[ducktape] object PlanConfigurer {

case parent @ BetweenCoproducts(sourceTpe, destTpe, casePlans) =>
def sideTpe(plan: Plan[Erroneous, Fallible]) =
if (config.side.isSource) plan.source.tpe.repr else plan.dest.tpe.repr
if config.side.isSource then plan.source.tpe.repr else plan.dest.tpe.repr

casePlans.zipWithIndex
.find((plan, _) => tpe.repr =:= sideTpe(plan))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package io.github.arainko.ducktape.internal

import io.github.arainko.ducktape.internal.*
import io.github.arainko.ducktape.internal.Context.{ PossiblyFallible, Total }
import io.github.arainko.ducktape.internal.Plan.{ Derived, UserDefined }
import io.github.arainko.ducktape.internal.Summoner.UserDefined.{ FallibleTransformer, TotalTransformer }
import io.github.arainko.ducktape.internal.*

import scala.collection.immutable.VectorMap
import scala.quoted.*
Expand Down Expand Up @@ -261,7 +261,7 @@ private[ducktape] object Planner {
case TransformationSite.Transformation if Depth.current == 1 =>
boundary[Plan.Error | plan.type]:
var owner = Symbol.spliceOwner
while (!owner.isNoSymbol) {
while !owner.isNoSymbol do {
if owner == transformerSymbol then boundary.break(Plan.Error.from(plan, ErrorMessage.LoopingTransformerDetected, None))
owner = owner.maybeOwner
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ private[ducktape] object ProductZipper {
private def unpackRight(expr: Expr[Any], times: Int)(using Quotes): quotes.reflect.Term = {
import quotes.reflect.*

if (times == 0) expr.asTerm
if times == 0 then expr.asTerm
else Select.unique(unpackRight(expr, times - 1), "_2")
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package io.github.arainko.ducktape.internal

import io.github.arainko.ducktape.internal.Structure.*
import io.github.arainko.ducktape.internal.*
import io.github.arainko.ducktape.internal.Structure.*

import scala.annotation.{ tailrec, unused }
import scala.collection.immutable.VectorMap
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ object Positive {
given Ordering[Positive] = Ordering.by(_.value)

given accTransformer: FallibleTransformer[AccumulatingFailure, Int, Positive] =
int => if (int > 0) Right(Positive(int)) else Left(s"$int" :: Nil)
int => if int > 0 then Right(Positive(int)) else Left(s"$int" :: Nil)

given failFastTransformer: FallibleTransformer[FailFastFailure, Int, Positive] =
int => accTransformer.transform(int).left.map(_.head)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ are being overriden by Field.allMatching(fieldSource)""")
value
.into[MoreCases]
.transform(
Case.computed[NotEnumMoreCases.Case4](case4 => if (case4.value == 1) MoreCases.Case1 else MoreCases.Case4)
Case.computed[NotEnumMoreCases.Case4](case4 => if case4.value == 1 then MoreCases.Case1 else MoreCases.Case4)
)

val expectedForValue1 = MoreCases.Case1
Expand Down
10 changes: 5 additions & 5 deletions project/Website.scala
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import laika.ast.LengthUnit.px
import laika.ast.Path.Root
import laika.ast._
import laika.ast.*
import laika.helium.Helium
import laika.helium.config._
import laika.helium.config.*
import laika.theme.config.Color
import org.typelevel.sbt.TypelevelGitHubPlugin.gitHubUserRepo
import org.typelevel.sbt.TypelevelSitePlugin.autoImport._
import org.typelevel.sbt.site._
import sbt.Def._
import org.typelevel.sbt.TypelevelSitePlugin.autoImport.*
import org.typelevel.sbt.site.*
import sbt.Def.*
import sbt.Keys.{ licenses, scmInfo }

object DeffSiteSettings {
Expand Down
2 changes: 1 addition & 1 deletion project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.5.2")
addSbtPlugin("org.scalameta" % "sbt-mdoc" % "2.5.4")
addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.11.1")
addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.12.1")
addSbtPlugin("org.typelevel" % "sbt-typelevel-ci-release" % "0.7.2")
addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.3.1")
addSbtPlugin("org.portable-scala" % "sbt-scala-native-crossproject" % "1.3.1")
Expand Down