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

More Scalafix #2888

Closed
wants to merge 2 commits into from
Closed
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class CaseClassQueryCassandraSpec extends CassandraAlpakkaSpec {
val peopleInsert =
quote((p: Contact) => query[Contact].insertValue(p))

val peopleEntries = List(
val peopleEntries: List[Contact] = List(
Contact(1, "Alex", "Jones", 60, 2, "foo"),
Contact(2, "Bert", "James", 55, 3, "bar"),
Contact(3, "Cora", "Jasper", 33, 3, "baz")
Expand All @@ -19,7 +19,7 @@ class CaseClassQueryCassandraSpec extends CassandraAlpakkaSpec {
val addressInsert =
quote((c: Address) => query[Address].insertValue(c))

val addressEntries = List(
val addressEntries: List[Address] = List(
Address(1, "123 Fake Street", 11234, "something"),
Address(2, "456 Old Street", 45678, "something else"),
Address(3, "789 New Street", 89010, "another thing")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import scala.util.Try
class CassandraContextSpec extends CassandraAlpakkaSpec {
import testDB._
"run non-batched action" in {
case class TestEntity(id: Int, s: String, i: Int, l: Long, o: Int)
final case class TestEntity(id: Int, s: String, i: Int, l: Long, o: Int)
val update = quote {
query[TestEntity].filter(_.id == lift(1)).update(_.i -> lift(1))
}
Expand All @@ -17,11 +17,11 @@ class CassandraContextSpec extends CassandraAlpakkaSpec {

"fail on returning" in {

val p: Prepare = (x, session) => (Nil, x)
val p: Prepare = (x, _) => (List.empty, x)
val e: Extractor[Int] = (_, _) => 1

intercept[IllegalStateException](executeActionReturning("", p, e, "")(ExecutionInfo.unknown, ())).getMessage mustBe
intercept[IllegalStateException](executeBatchActionReturning(Nil, e)(ExecutionInfo.unknown, ())).getMessage
intercept[IllegalStateException](executeBatchActionReturning(List.empty, e)(ExecutionInfo.unknown, ())).getMessage
}

"return failed future on `prepare` error in async context" - {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ class DecodeNullSpec extends CassandraAlpakkaSpec {

case class DecodeNullTestWriteEntity(id: Int, value: Option[Int])

val insertValue = DecodeNullTestWriteEntity(0, None)
val insertValue: DecodeNullTestWriteEntity = DecodeNullTestWriteEntity(0, None)

}
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,18 @@ class EncodingSpec extends EncodingSpecHelper with CassandraAlpakkaSpec {

"mappedEncoding" in {
import testDB._
case class A()
case class B()
val a1: Encoder[A] = encoder((b, c, d, s) => d)
val a2: Decoder[A] = decoder((b, c, s) => A())
final case class A()
final case class B()
val a1: Encoder[A] = encoder((_, _, d, _) => d)
val a2: Decoder[A] = decoder((_, _, _) => A())
mappedDecoder(MappedEncoding[A, B](_ => B()), a2).isInstanceOf[CassandraDecoder[B]] mustBe true
mappedEncoder(MappedEncoding[B, A](_ => A()), a1).isInstanceOf[CassandraEncoder[B]] mustBe true
}

"date and timestamps" - {
import testDB._
case class Java8Types(v9: LocalDate, v11: Instant, o9: Option[ZonedDateTime], id: Int = 1, v1: String = "")
case class CasTypes(v9: LocalDate, v11: Instant, o9: Option[ZonedDateTime], id: Int = 1, v1: String = "")
final case class Java8Types(v9: LocalDate, v11: Instant, o9: Option[ZonedDateTime], id: Int = 1, v1: String = "")
final case class CasTypes(v9: LocalDate, v11: Instant, o9: Option[ZonedDateTime], id: Int = 1, v1: String = "")

"mirror" in {
implicitly[Encoder[LocalDate]]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import io.getquill.context.cassandra.CollectionsSpec

import java.time.{Instant, LocalDate}
import java.util.UUID
import io.getquill.{EntityQuery, Quoted}

class ListsEncodingSpec extends CollectionsSpec with CassandraAlpakkaSpec {
val ctx = testDB
Expand All @@ -25,7 +26,7 @@ class ListsEncodingSpec extends CollectionsSpec with CassandraAlpakkaSpec {
uuids: List[UUID]
)

val e = ListsEntity(
val e: ListsEntity = ListsEntity(
1,
List("c"),
List(BigDecimal(1.33)),
Expand All @@ -41,7 +42,7 @@ class ListsEncodingSpec extends CollectionsSpec with CassandraAlpakkaSpec {
List(UUID.randomUUID())
)

val q = quote(query[ListsEntity])
val q: Quoted[EntityQuery[ListsEntity]] = quote(query[ListsEntity])

"List encoders/decoders for CassandraTypes and CassandraMappers" in {
await {
Expand All @@ -55,8 +56,8 @@ class ListsEncodingSpec extends CollectionsSpec with CassandraAlpakkaSpec {
}

"Empty lists and optional fields" in {
case class Entity(id: Int, texts: Option[List[String]], bools: Option[List[Boolean]], ints: List[Int])
val e = Entity(1, Some(List("1", "2")), None, Nil)
final case class Entity(id: Int, texts: Option[List[String]], bools: Option[List[Boolean]], ints: List[Int])
val e = Entity(1, Some(List("1", "2")), None, List.empty)
val q = quote(querySchema[Entity]("ListsEntity"))

await {
Expand All @@ -70,7 +71,7 @@ class ListsEncodingSpec extends CollectionsSpec with CassandraAlpakkaSpec {
}

"Mapped encoding for CassandraType" in {
case class StrEntity(id: Int, texts: List[StrWrap])
final case class StrEntity(id: Int, texts: List[StrWrap])
val e = StrEntity(1, List("1", "2").map(StrWrap.apply))
val q = quote(querySchema[StrEntity]("ListsEntity"))

Expand All @@ -85,7 +86,7 @@ class ListsEncodingSpec extends CollectionsSpec with CassandraAlpakkaSpec {
}

"Mapped encoding for CassandraMapper types" in {
case class IntEntity(id: Int, ints: List[IntWrap])
final case class IntEntity(id: Int, ints: List[IntWrap])
val e = IntEntity(1, List(1, 2).map(IntWrap.apply))
val q = quote(querySchema[IntEntity]("ListsEntity"))

Expand All @@ -100,7 +101,7 @@ class ListsEncodingSpec extends CollectionsSpec with CassandraAlpakkaSpec {
}

"Blob (Array[Byte]) support" in {
case class BlobsEntity(id: Int, blobs: List[Array[Byte]])
final case class BlobsEntity(id: Int, blobs: List[Array[Byte]])
val e = BlobsEntity(4, List(Array(1.toByte, 2.toByte), Array(2.toByte)))
val q = quote(querySchema[BlobsEntity]("ListsEntity"))

Expand All @@ -123,7 +124,7 @@ class ListsEncodingSpec extends CollectionsSpec with CassandraAlpakkaSpec {
res2 <- ctx.run(listFroz.filter(_.id == lift(List(1))))
} yield {
res1 mustBe List(e)
res2 mustBe Nil
res2 mustBe List.empty
}
}
await {
Expand All @@ -133,7 +134,7 @@ class ListsEncodingSpec extends CollectionsSpec with CassandraAlpakkaSpec {
res2 <- ctx.run(listFroz.filter(_.id.contains(3)).allowFiltering)
} yield {
res1 mustBe List(e)
res2 mustBe Nil
res2 mustBe List.empty
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import io.getquill.context.cassandra.CollectionsSpec

import java.time.{Instant, LocalDate}
import java.util.UUID
import io.getquill.{EntityQuery, Quoted}

class MapsEncodingSpec extends CollectionsSpec with CassandraAlpakkaSpec {
val ctx = testDB
Expand All @@ -18,15 +19,15 @@ class MapsEncodingSpec extends CollectionsSpec with CassandraAlpakkaSpec {
uuidTimestamp: Map[UUID, Instant]
)

val e = MapsEntity(
val e: MapsEntity = MapsEntity(
1,
Map("1" -> BigDecimal(1)),
Map(1 -> 1d, 2 -> 2d, 3 -> 3d),
Map(1L -> 3f),
Map(true -> LocalDate.now()),
Map(UUID.randomUUID() -> Instant.now())
)
val q = quote(query[MapsEntity])
val q: Quoted[EntityQuery[MapsEntity]] = quote(query[MapsEntity])

"Map encoders/decoders" in {
await {
Expand All @@ -40,13 +41,13 @@ class MapsEncodingSpec extends CollectionsSpec with CassandraAlpakkaSpec {
}

"Empty maps and optional fields" in {
case class Entity(
final case class Entity(
id: Int,
textDecimal: Option[Map[String, BigDecimal]],
intDouble: Option[Map[Int, Double]],
longFloat: Map[Long, Float]
)
val e = Entity(1, Some(Map("1" -> BigDecimal(1))), None, Map())
val e = Entity(1, Some(Map("1" -> BigDecimal(1))), None, Map.empty)
val q = quote(querySchema[Entity]("MapsEntity"))

await {
Expand All @@ -60,7 +61,7 @@ class MapsEncodingSpec extends CollectionsSpec with CassandraAlpakkaSpec {
}

"Mapped encoding for CassandraType" in {
case class StrEntity(id: Int, textDecimal: Map[StrWrap, BigDecimal])
final case class StrEntity(id: Int, textDecimal: Map[StrWrap, BigDecimal])
val e = StrEntity(1, Map(StrWrap("1") -> BigDecimal(1)))
val q = quote(querySchema[StrEntity]("MapsEntity"))

Expand All @@ -75,7 +76,7 @@ class MapsEncodingSpec extends CollectionsSpec with CassandraAlpakkaSpec {
}

"Mapped encoding for CassandraMapper types" in {
case class IntEntity(id: Int, intDouble: Map[IntWrap, Double])
final case class IntEntity(id: Int, intDouble: Map[IntWrap, Double])
val e = IntEntity(1, Map(IntWrap(1) -> 1d))
val q = quote(querySchema[IntEntity]("MapsEntity"))

Expand All @@ -99,7 +100,7 @@ class MapsEncodingSpec extends CollectionsSpec with CassandraAlpakkaSpec {
res2 <- ctx.run(mapFroz.filter(_.id == lift(Map(1 -> false))))
} yield {
res1 mustBe List(e)
res2 mustBe Nil
res2 mustBe List.empty
}
}
await {
Expand All @@ -109,7 +110,7 @@ class MapsEncodingSpec extends CollectionsSpec with CassandraAlpakkaSpec {
res2 <- ctx.run(mapFroz.filter(_.id.contains(2)).allowFiltering)
} yield {
res1 mustBe List(e)
res2 mustBe Nil
res2 mustBe List.empty
}
}
}
Expand All @@ -124,7 +125,7 @@ class MapsEncodingSpec extends CollectionsSpec with CassandraAlpakkaSpec {
res2 <- ctx.run(mapFroz.filter(_.id.containsValue(false)).allowFiltering)
} yield {
res1 mustBe List(e)
res2 mustBe Nil
res2 mustBe List.empty
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ class PeopleCassandraSpec extends CassandraAlpakkaSpec {

case class Person(id: Int, name: String, age: Int)

val entries = List(
val entries: List[Person] = List(
Person(1, "Bob", 30),
Person(2, "Gus", 40),
Person(3, "Pet", 20),
Person(4, "Don", 50),
Person(5, "Dre", 60)
)

override def beforeAll = {
override def beforeAll: Unit = {
await {
testDB.run(query[Person].delete)
}
Expand All @@ -27,11 +27,11 @@ class PeopleCassandraSpec extends CassandraAlpakkaSpec {
()
}

val qByIds = quote { (ids: Query[Int]) =>
val qByIds: Quoted[Query[Int] => EntityQuery[Person]] = quote { (ids: Query[Int]) =>
query[Person].filter(p => ids.contains(p.id))
}

val q = quote {
val q: Quoted[EntityQuery[Person]] = quote {
query[Person]
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class QueryResultTypeCassandraAsyncSpec extends QueryResultTypeCassandraSpec wit
val context = testDB
import context._

override def beforeAll = {
override def beforeAll: Unit = {
await(context.run(deleteAll))
await(context.run(liftQuery(entries).foreach(e => insert(e))))
()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import io.getquill.context.cassandra.CollectionsSpec

import java.time.{Instant, LocalDate}
import java.util.UUID
import io.getquill.{EntityQuery, Quoted}

class SetsEncodingSpec extends CollectionsSpec with CassandraAlpakkaSpec {
val ctx = testDB
Expand All @@ -23,7 +24,7 @@ class SetsEncodingSpec extends CollectionsSpec with CassandraAlpakkaSpec {
timestamps: Set[Instant],
uuids: Set[UUID]
)
val e = SetsEntity(
val e: SetsEntity = SetsEntity(
1,
Set("c"),
Set(BigDecimal(1.33)),
Expand All @@ -36,7 +37,7 @@ class SetsEncodingSpec extends CollectionsSpec with CassandraAlpakkaSpec {
Set(Instant.now()),
Set(UUID.randomUUID())
)
val q = quote(query[SetsEntity])
val q: Quoted[EntityQuery[SetsEntity]] = quote(query[SetsEntity])
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TO REMOVE


"Set encoders/decoders for CassandraTypes and CassandraMappers" in {
await {
Expand All @@ -50,7 +51,7 @@ class SetsEncodingSpec extends CollectionsSpec with CassandraAlpakkaSpec {
}

"Empty sets and optional fields" in {
case class Entity(id: Int, texts: Option[Set[String]], bools: Option[Set[Boolean]], ints: Set[Int])
final case class Entity(id: Int, texts: Option[Set[String]], bools: Option[Set[Boolean]], ints: Set[Int])
val e = Entity(1, Some(Set("1", "2")), None, Set.empty)
val q = quote(querySchema[Entity]("SetsEntity"))

Expand All @@ -65,7 +66,7 @@ class SetsEncodingSpec extends CollectionsSpec with CassandraAlpakkaSpec {
}

"Mapped encoding for CassandraType" in {
case class StrEntity(id: Int, texts: Set[StrWrap])
final case class StrEntity(id: Int, texts: Set[StrWrap])
val e = StrEntity(1, Set("1", "2").map(StrWrap.apply))
val q = quote(querySchema[StrEntity]("SetsEntity"))

Expand All @@ -80,7 +81,7 @@ class SetsEncodingSpec extends CollectionsSpec with CassandraAlpakkaSpec {
}

"Mapped encoding for CassandraMapper types" in {
case class IntEntity(id: Int, ints: Set[IntWrap])
final case class IntEntity(id: Int, ints: Set[IntWrap])
val e = IntEntity(1, Set(1, 2).map(IntWrap.apply))
val q = quote(querySchema[IntEntity]("SetsEntity"))

Expand All @@ -95,7 +96,7 @@ class SetsEncodingSpec extends CollectionsSpec with CassandraAlpakkaSpec {
}

"Blob (Array[Byte]) support" in {
case class BlobsEntity(id: Int, blobs: Set[Array[Byte]])
final case class BlobsEntity(id: Int, blobs: Set[Array[Byte]])
val e = BlobsEntity(4, Set(Array(1.toByte, 2.toByte), Array(2.toByte)))
val q = quote(querySchema[BlobsEntity]("SetsEntity"))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ class UdtEncodingSessionContextSpec extends UdtSpec with CassandraAlpakkaSpec {
implicitly[Encoder[List[Personal]]]
}
"MappedEncoding" in {
case class FirstName(name: String)
case class MyName(firstName: FirstName) extends Udt
final case class FirstName(name: String)
final case class MyName(firstName: FirstName) extends Udt

implicit val encodeFirstName = MappedEncoding[FirstName, String](_.name)
implicit val decodeFirstName = MappedEncoding[String, FirstName](FirstName)
Expand All @@ -45,7 +45,7 @@ class UdtEncodingSessionContextSpec extends UdtSpec with CassandraAlpakkaSpec {
"Complete examples" - {
import ctx1._
"without meta" in {
case class WithEverything(id: Int, personal: Personal, nameList: List[Name])
final case class WithEverything(id: Int, personal: Personal, nameList: List[Name])

val e = WithEverything(
1,
Expand All @@ -71,8 +71,8 @@ class UdtEncodingSessionContextSpec extends UdtSpec with CassandraAlpakkaSpec {
}
}
"with meta" in {
case class MyName(first: String) extends Udt
case class WithEverything(id: Int, name: MyName, nameList: List[MyName])
final case class MyName(first: String) extends Udt
final case class WithEverything(id: Int, name: MyName, nameList: List[MyName])
implicit val myNameMeta = udtMeta[MyName]("Name", _.first -> "firstName")

val e = WithEverything(2, MyName("first"), List(MyName("first")))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package io.getquill.context.cassandra.monix

import io.getquill._
import io.getquill.base.Spec

class DecodeNullSpec extends Spec {
Expand Down Expand Up @@ -31,5 +30,5 @@ class DecodeNullSpec extends Spec {

case class DecodeNullTestWriteEntity(id: Int, value: Option[Int])

val insertValue = DecodeNullTestWriteEntity(0, None)
val insertValue: DecodeNullTestWriteEntity = DecodeNullTestWriteEntity(0, None)
}
Loading
Loading