Skip to content
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

Fix compilation warnings #59

Merged
merged 1 commit into from
Mar 13, 2024
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
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package ru.tinkoff.tcb.bson.derivation

import derevo.derive
import org.mongodb.scala.bson.BsonDocument
import org.scalacheck.Arbitrary
import org.scalacheck.Gen
Expand All @@ -10,17 +9,8 @@ import org.scalatest.matchers.should.Matchers
import org.scalatestplus.scalacheck.Checkers

import ru.tinkoff.tcb.bson.*
import ru.tinkoff.tcb.bson.annotation.BsonDiscriminator

class DerivedCodecsSuite extends AnyFunSuite with Checkers with Matchers with TryValues {

// Stolen from http://github.com/travisbrown/circe
@derive(bsonDecoder, bsonEncoder) @BsonDiscriminator("case", _.reverse)
sealed trait RecursiveAdtExample
final case class BaseAdtExample(a: String) extends RecursiveAdtExample
final case class NestedAdtExample(r: RecursiveAdtExample) extends RecursiveAdtExample
object RecursiveAdtExample

private def atDepth(depth: Int): Gen[RecursiveAdtExample] =
if (depth < 3)
Gen.oneOf(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import java.time.Year

import derevo.derive

import ru.tinkoff.tcb.bson.annotation.BsonDiscriminator
import ru.tinkoff.tcb.bson.annotation.BsonKey

@derive(bsonDecoder, bsonEncoder)
Expand Down Expand Up @@ -35,3 +36,10 @@ final case class TestEntityWithDefaults(
linkId: Option[Int],
checks: Seq[TestCheck] = Seq()
)

// Stolen from http://github.com/travisbrown/circe
@derive(bsonDecoder, bsonEncoder) @BsonDiscriminator("case", _.reverse)
sealed trait RecursiveAdtExample
final case class BaseAdtExample(a: String) extends RecursiveAdtExample
final case class NestedAdtExample(r: RecursiveAdtExample) extends RecursiveAdtExample
object RecursiveAdtExample
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import org.scalatest.funsuite.AnyFunSuite
import org.scalatest.matchers.should.Matchers

class FieldsSpec extends AnyFunSuite with Matchers {
case class Evidence()

test("Fields of empty case class") {
Fields[Evidence].fields shouldBe Nil
}
Expand All @@ -16,11 +14,13 @@ class FieldsSpec extends AnyFunSuite with Matchers {
Fields[Projection].fields shouldBe List("ev", "label")
}

sealed trait ST
final case class A(a: Int) extends ST
final case class B(b: Int) extends ST

test("Fields of sealed trait") {
Fields[ST].fields shouldBe Nil
}
}

final case class Evidence()

sealed trait ST
final case class A(a: Int) extends ST
final case class B(b: Int) extends ST
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +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

/*
Rewritten from https://github.com/line/armeria/blob/main/core/src/main/java/com/linecorp/armeria/client/IgnoreHostsTrustManager.java
Expand Down Expand Up @@ -47,8 +48,9 @@ class TrustSomeHostsManager(delegate: X509ExtendedTrustManager, insecureHosts: S
}

object TrustSomeHostsManager {
@nowarn("cat=lint-nonlocal-return")
def of(insecureHosts: Set[String]): TrustSomeHostsManager = {
var trustManagerFactory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm)
val trustManagerFactory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm)
trustManagerFactory.init(null.asInstanceOf[KeyStore])
val trustManagers = trustManagerFactory.getTrustManagers
for (tm <- trustManagers)
Expand Down