Skip to content

Commit

Permalink
Run linters
Browse files Browse the repository at this point in the history
  • Loading branch information
danslapman committed Jan 5, 2025
1 parent a2a3c0a commit 676f217
Show file tree
Hide file tree
Showing 82 changed files with 499 additions and 314 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package ru.tinkoff.tcb.bson

import oolong.bson.*
import oolong.bson.given

import scala.jdk.CollectionConverters.*

import oolong.bson.*
import org.mongodb.scala.bson.*

import ru.tinkoff.tcb.generic.RootOptionFields

object PatchGenerator {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package ru.tinkoff.tcb.bson.enumeratum

import enumeratum.*
import oolong.bson.{BsonDecoder, BsonEncoder}
import oolong.bson.BsonDecoder
import oolong.bson.BsonEncoder

trait BsonEnum[A <: EnumEntry] { self: Enum[A] =>
implicit val bsonEncoder: BsonEncoder[A] =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package ru.tinkoff.tcb.bson.enumeratum

import scala.util.Failure
import scala.util.Try

import enumeratum.*
import oolong.bson.*
import org.mongodb.scala.bson.*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
package ru.tinkoff.tcb.bson.enumeratum.values

import scala.util.Try

import enumeratum.values.*
import oolong.bson.{BsonDecoder, BsonEncoder, BsonKeyDecoder, BsonKeyEncoder}
import oolong.bson.BsonDecoder
import oolong.bson.BsonEncoder
import oolong.bson.BsonKeyDecoder
import oolong.bson.BsonKeyEncoder
import oolong.bson.given

trait BsonValueEnum[ValueType, EntryType <: ValueEnumEntry[ValueType]] {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package ru.tinkoff.tcb.bson.enumeratum.values

import enumeratum.values.*
import oolong.bson.{BsonDecoder, BsonEncoder}
import oolong.bson.given
import oolong.bson.BsonDecoder
import oolong.bson.BsonEncoder
import org.mongodb.scala.bson.*

object EnumHandler {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package ru.tinkoff.tcb.bson.optics

import scala.annotation.nowarn
import scala.util.Try

import oolong.bson.*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,28 +14,43 @@ trait PropSubset[Projection, Source]

type GetByLabel[TL <: String, TPL <: Tuple] =
TPL match
case (TL, t) *: _ => t
case (TL, t) *: _ => t
case _ *: (t *: ts) => GetByLabel[TL, t *: ts]

object PropSubset {
private val anySubset = new PropSubset[Any, Any] {}

given [T]: PropSubset[T, T] = anySubset.asInstanceOf[PropSubset[T, T]]

given [P, S](using NotGiven[P =:= S], PropSubset[P, S]): PropSubset[Option[P], Option[S]] = anySubset.asInstanceOf[PropSubset[Option[P], Option[S]]]
given [P, S](using NotGiven[P =:= S], PropSubset[P, S]): PropSubset[Option[P], Option[S]] =
anySubset.asInstanceOf[PropSubset[Option[P], Option[S]]]

given [K, P, S](using NotGiven[P =:= S], PropSubset[P, S]): PropSubset[K Map P, K Map S] = anySubset.asInstanceOf[PropSubset[K Map P, K Map S]]
given [K, P, S](using NotGiven[P =:= S], PropSubset[P, S]): PropSubset[K Map P, K Map S] =
anySubset.asInstanceOf[PropSubset[K Map P, K Map S]]

given [P, S](using NotGiven[P =:= S], PropSubset[P, S]): PropSubset[Set[P], Set[S]] = anySubset.asInstanceOf[PropSubset[Set[P], Set[S]]]
given [P, S](using NotGiven[P =:= S], PropSubset[P, S]): PropSubset[Set[P], Set[S]] =
anySubset.asInstanceOf[PropSubset[Set[P], Set[S]]]

given [P, S, R, F[_, _]](using RefType[F], PropSubset[P, S]): PropSubset[F[P, R], S] = anySubset.asInstanceOf[PropSubset[F[P, R], S]]
given [P, S, R, F[_, _]](using RefType[F], PropSubset[P, S]): PropSubset[F[P, R], S] =
anySubset.asInstanceOf[PropSubset[F[P, R], S]]

given [P, S, R, F[_, _]](using NotGiven[P =:= S], RefType[F], PropSubset[P, S]): PropSubset[F[P, R], F[S, R]] = anySubset.asInstanceOf[PropSubset[F[P, R], F[S, R]]]
given [P, S, R, F[_, _]](using NotGiven[P =:= S], RefType[F], PropSubset[P, S]): PropSubset[F[P, R], F[S, R]] =
anySubset.asInstanceOf[PropSubset[F[P, R], F[S, R]]]

given [T <: Tuple]: PropSubset[EmptyTuple, T] = anySubset.asInstanceOf[PropSubset[EmptyTuple, T]]

given [PHL <: String, PHT, PT <: Tuple, S <: Tuple](using PropSubset[PHT, GetByLabel[PHL, S]], PropSubset[PT, S]): PropSubset[(PHL, PHT) *: PT, S] = anySubset.asInstanceOf[PropSubset[(PHL, PHT) *: PT, S]]

given [P <: Product, S <: Product](using mp: Mirror.ProductOf[P], ms: Mirror.ProductOf[S], tps: PropSubset[Tuple.Zip[mp.MirroredElemLabels, mp.MirroredElemTypes], Tuple.Zip[ms.MirroredElemLabels, ms.MirroredElemTypes]]): PropSubset[P, S] =
given [PHL <: String, PHT, PT <: Tuple, S <: Tuple](using
PropSubset[PHT, GetByLabel[PHL, S]],
PropSubset[PT, S]
): PropSubset[(PHL, PHT) *: PT, S] = anySubset.asInstanceOf[PropSubset[(PHL, PHT) *: PT, S]]

given [P <: Product, S <: Product](using
mp: Mirror.ProductOf[P],
ms: Mirror.ProductOf[S],
tps: PropSubset[
Tuple.Zip[mp.MirroredElemLabels, mp.MirroredElemTypes],
Tuple.Zip[ms.MirroredElemLabels, ms.MirroredElemTypes]
]
): PropSubset[P, S] =
anySubset.asInstanceOf[PropSubset[P, S]]
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import java.time.Year
import scala.annotation.implicitNotFound

import eu.timepit.refined.api.RefType

import magnolia1.*

@implicitNotFound("Could not find an instance of RootOptionFields for ${T}")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package ru.tinkoff.tcb.mongo

import scala.jdk.CollectionConverters.*

import oolong.bson.*
import oolong.bson.given
import org.mongodb.scala.MongoClient.DEFAULT_CODEC_REGISTRY
import org.mongodb.scala.MongoCollection
import org.mongodb.scala.Observer
Expand All @@ -9,8 +12,7 @@ import org.mongodb.scala.bson.*
import org.mongodb.scala.bson.conversions.Bson
import org.mongodb.scala.model.IndexOptions
import org.mongodb.scala.model.changestream.*
import oolong.bson.*
import oolong.bson.given

import ru.tinkoff.tcb.bson.PatchGenerator
import ru.tinkoff.tcb.dataaccess.UpdateResult
import ru.tinkoff.tcb.generic.Fields
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package ru.tinkoff.tcb.mongo

import oolong.bson.{BsonDecoder, BsonEncoder}
import oolong.bson.BsonDecoder
import oolong.bson.BsonEncoder
import oolong.bson.given
import org.mongodb.scala.bson.Document
import org.mongodb.scala.bson.conversions.Bson
import org.mongodb.scala.model.IndexOptions
import org.mongodb.scala.model.changestream.ChangeStreamDocument

import ru.tinkoff.tcb.dataaccess.DAO
import ru.tinkoff.tcb.dataaccess.UpdateResult
import ru.tinkoff.tcb.generic.Fields
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
package ru.tinkoff.tcb.bson

import oolong.bson.*
import oolong.bson.given
import org.mongodb.scala.bson.BsonDocument
import org.scalatest.funsuite.AnyFunSuite
import org.scalatest.matchers.should.Matchers

import oolong.bson.*
import oolong.bson.given

final case class TestEntity(_id: String, name: String, externalKey: Option[Int]) derives BsonDecoder, BsonEncoder

class PatchGeneratorSpec extends AnyFunSuite with Matchers {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package ru.tinkoff.tcb.bson.enumeratum

import oolong.bson.*
import oolong.bson.given
import org.mongodb.scala.bson.*
import org.scalatest.funspec.AnyFunSpec
import org.scalatest.matchers.should.Matchers
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
package ru.tinkoff.tcb.bson.enumeratum

import oolong.bson.*
import org.mongodb.scala.bson.*
import org.scalatest.OptionValues.*
import org.scalatest.funspec.AnyFunSpec
import org.scalatest.matchers.should.Matchers

import oolong.bson.*
import oolong.bson.given

class EnumBsonHandlerSpec extends AnyFunSpec with Matchers {
testScenario(
descriptor = "normal operation (no transformations)",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package ru.tinkoff.tcb.bson.enumeratum.values

import enumeratum.values.*
import oolong.bson.*
import oolong.bson.given
import org.mongodb.scala.bson.*
import org.scalatest.funspec.AnyFunSpec
import org.scalatest.matchers.should.Matchers
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ class UIHttp {
.zServerLogic[WLD](_ => ZIO.succeed(json"""{"version": ${BuildInfo.version}}"""))

private val staticEndpoint: ZServerEndpoint[WLD, Any] =
staticResourcesGetServerEndpoint[[X] =>> RIO[WLD, X]]("mockingbird" / "assets")(this.getClass.getClassLoader, "out/assets")
staticResourcesGetServerEndpoint[[X] =>> RIO[WLD, X]]("mockingbird" / "assets")(
this.getClass.getClassLoader,
"out/assets"
)

private val indexEndpoint: ZServerEndpoint[WLD, Any] =
resourcesGetServerEndpoint2("mockingbird")(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import ru.tinkoff.tcb.mockingbird.model.XmlProxyResponse
import ru.tinkoff.tcb.mockingbird.model.XmlResponse
import ru.tinkoff.tcb.utils.xml.XMLStringSyntax


package object codec {
implicit val throwableCodec: Codec[String, Throwable, CodecFormat.TextPlain] =
Codec.string.map[Throwable](new Exception(_: String))(_.toString)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import io.circe.Json
import io.circe.JsonNumber
import io.circe.JsonObject
import oolong.bson.*
import oolong.bson.given
import org.bson.BsonInvalidOperationException
import org.bson.types.Decimal128
import org.mongodb.scala.bson.*
Expand Down
Loading

0 comments on commit 676f217

Please sign in to comment.