diff --git a/backend/circe-utils/src/main/scala/ru/tinkoff/tcb/utils/circe/optics/PathPart.scala b/backend/circe-utils/src/main/scala/ru/tinkoff/tcb/utils/circe/optics/PathPart.scala index 29e3113e..c60b77d2 100644 --- a/backend/circe-utils/src/main/scala/ru/tinkoff/tcb/utils/circe/optics/PathPart.scala +++ b/backend/circe-utils/src/main/scala/ru/tinkoff/tcb/utils/circe/optics/PathPart.scala @@ -10,4 +10,4 @@ sealed private[optics] trait PathPart { } final private[optics] case class Field(name: String) extends PathPart final private[optics] case class Index(index: Int) extends PathPart -final private[optics] case object Traverse extends PathPart +private[optics] case object Traverse extends PathPart diff --git a/backend/dataAccess/src/main/scala/ru/tinkoff/tcb/mongo/DAOBase.scala b/backend/dataAccess/src/main/scala/ru/tinkoff/tcb/mongo/DAOBase.scala index 84263a05..bd9d9fbc 100644 --- a/backend/dataAccess/src/main/scala/ru/tinkoff/tcb/mongo/DAOBase.scala +++ b/backend/dataAccess/src/main/scala/ru/tinkoff/tcb/mongo/DAOBase.scala @@ -6,12 +6,10 @@ 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 import org.mongodb.scala.SingleObservableFuture 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 ru.tinkoff.tcb.bson.PatchGenerator import ru.tinkoff.tcb.dataaccess.UpdateResult @@ -168,33 +166,6 @@ abstract class DAOBase[T: BsonDecoder: BsonEncoder]( insert(create).map(UpdateResult(0, _)) } - override def subscribe(consumer: ChangeStreamDocument[T] => Unit): Unit = - collection - .watch() - .fullDocument(FullDocument.UPDATE_LOOKUP) - .subscribe(new Observer[ChangeStreamDocument[BsonDocument]] { - override def onNext(result: ChangeStreamDocument[BsonDocument]): Unit = - consumer( - new ChangeStreamDocument[T]( - result.getOperationType, - result.getResumeToken, - result.getNamespaceDocument, - result.getDestinationNamespaceDocument, - BsonDecoder[T].fromBson(result.getFullDocument).get, - result.getDocumentKey, - result.getClusterTime, - result.getUpdateDescription, - result.getTxnNumber, - result.getLsid - ) - ) - - override def onError(e: Throwable): Unit = - subscribe(consumer) - - override def onComplete(): Unit = () - }) - override def createIndex(defn: Sort, options: IndexOptions): Task[Unit] = ZIO.fromFuture(implicit ec => collection.createIndex(defn, options).head()).unit } diff --git a/backend/dataAccess/src/main/scala/ru/tinkoff/tcb/mongo/MongoDAO.scala b/backend/dataAccess/src/main/scala/ru/tinkoff/tcb/mongo/MongoDAO.scala index 8d6ffc0c..b099a1ef 100644 --- a/backend/dataAccess/src/main/scala/ru/tinkoff/tcb/mongo/MongoDAO.scala +++ b/backend/dataAccess/src/main/scala/ru/tinkoff/tcb/mongo/MongoDAO.scala @@ -6,7 +6,6 @@ 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 @@ -53,8 +52,6 @@ trait MongoDAO[F[_], T] extends DAO[F, T] { ps: PropSubset[P, T] ): F[UpdateResult] - def subscribe(consumer: ChangeStreamDocument[T] => Unit): Unit - def createIndex(fields: Sort, options: IndexOptions = IndexOptions()): F[Unit] } diff --git a/backend/mockingbird-api/src/main/scala/ru/tinkoff/tcb/mockingbird/Mockingbird.scala b/backend/mockingbird-api/src/main/scala/ru/tinkoff/tcb/mockingbird/Mockingbird.scala index e43daac8..e7ca1bed 100644 --- a/backend/mockingbird-api/src/main/scala/ru/tinkoff/tcb/mockingbird/Mockingbird.scala +++ b/backend/mockingbird-api/src/main/scala/ru/tinkoff/tcb/mockingbird/Mockingbird.scala @@ -4,6 +4,7 @@ import java.net.http.HttpClient import java.security.SecureRandom import javax.net.ssl.KeyManagerFactory import javax.net.ssl.SSLContext +import scala.annotation.nowarn import scala.jdk.DurationConverters.* import com.mongodb.ConnectionString @@ -213,6 +214,7 @@ object Mockingbird { _ = builder.build().start() } yield () + @nowarn("name=ValueDiscarding") def main(args: Array[String]): Unit = Unsafe.unsafe { implicit us => wldRuntime.unsafe.run { diff --git a/backend/mockingbird-api/src/main/scala/ru/tinkoff/tcb/mockingbird/TrustSomeHostsManager.scala b/backend/mockingbird-api/src/main/scala/ru/tinkoff/tcb/mockingbird/TrustSomeHostsManager.scala index 15261a45..9ed56dfe 100644 --- a/backend/mockingbird-api/src/main/scala/ru/tinkoff/tcb/mockingbird/TrustSomeHostsManager.scala +++ b/backend/mockingbird-api/src/main/scala/ru/tinkoff/tcb/mockingbird/TrustSomeHostsManager.scala @@ -7,7 +7,7 @@ import java.security.cert.X509Certificate import javax.net.ssl.SSLEngine import javax.net.ssl.TrustManagerFactory import javax.net.ssl.X509ExtendedTrustManager -import scala.annotation.nowarn +import scala.util.boundary /* Rewritten from https://github.com/line/armeria/blob/main/core/src/main/java/com/linecorp/armeria/client/IgnoreHostsTrustManager.java @@ -48,15 +48,15 @@ class TrustSomeHostsManager(delegate: X509ExtendedTrustManager, insecureHosts: S } object TrustSomeHostsManager { - @nowarn("cat=lint-nonlocal-return") - def of(insecureHosts: Set[String]): TrustSomeHostsManager = { - val trustManagerFactory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm) - trustManagerFactory.init(null.asInstanceOf[KeyStore]) - val trustManagers = trustManagerFactory.getTrustManagers - for (tm <- trustManagers) - if (tm.isInstanceOf[X509ExtendedTrustManager]) - return new TrustSomeHostsManager(tm.asInstanceOf[X509ExtendedTrustManager], insecureHosts) - - throw new NoSuchElementException("cannot resolve default trust manager") - } + def of(insecureHosts: Set[String]): TrustSomeHostsManager = + boundary { + val trustManagerFactory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm) + trustManagerFactory.init(null.asInstanceOf[KeyStore]) + val trustManagers = trustManagerFactory.getTrustManagers + for (tm <- trustManagers) + if (tm.isInstanceOf[X509ExtendedTrustManager]) + boundary.break(new TrustSomeHostsManager(tm.asInstanceOf[X509ExtendedTrustManager], insecureHosts)) + + throw new NoSuchElementException("cannot resolve default trust manager") + } } diff --git a/backend/mockingbird/src/main/scala/ru/tinkoff/tcb/mockingbird/model/HttpStubRequest.scala b/backend/mockingbird/src/main/scala/ru/tinkoff/tcb/mockingbird/model/HttpStubRequest.scala index a496d094..e326f7ff 100644 --- a/backend/mockingbird/src/main/scala/ru/tinkoff/tcb/mockingbird/model/HttpStubRequest.scala +++ b/backend/mockingbird/src/main/scala/ru/tinkoff/tcb/mockingbird/model/HttpStubRequest.scala @@ -41,9 +41,8 @@ sealed trait HttpStubRequest derives BsonDecoder, BsonEncoder { def checkHeaders(hs: Map[String, String]): Boolean = headers.forall { case (k, v) => - hs.exists { - case (kx, vx) => k.toLowerCase == kx.toLowerCase && v == vx - case _ => false + hs.exists { case (kx, vx) => + k.toLowerCase == kx.toLowerCase && v == vx } } @@ -235,9 +234,8 @@ sealed trait RequestPart derives BsonDecoder, BsonEncoder { def checkHeaders(hs: Map[String, String]): Boolean = headers.forall { case (k, v) => - hs.exists { - case (kx, vx) => k.toLowerCase == kx.toLowerCase && v == vx - case _ => false + hs.exists { case (kx, vx) => + k.toLowerCase == kx.toLowerCase && v == vx } } diff --git a/backend/project/Settings.scala b/backend/project/Settings.scala index 99129c05..d1924454 100644 --- a/backend/project/Settings.scala +++ b/backend/project/Settings.scala @@ -49,7 +49,7 @@ object Settings { "-Yretain-trees", //for accessing default values by magnolia prelude(), // standart imports + zio // warning settings - //"-Wconf:any:wv", // shows warning categories for nowarn (https://www.scala-lang.org/2021/01/12/configuring-and-suppressing-warnings.html) + "-Wconf:any:v", // shows warning categories for nowarn (https://www.scala-lang.org/2021/01/12/configuring-and-suppressing-warnings.html) "-Wunused:imports", "-Wunused:privates", "-Wvalue-discard"