Skip to content

Commit

Permalink
Fix most warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
MateuszKubuszok committed Aug 18, 2024
1 parent e20fb55 commit 08724b3
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 18 deletions.
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
package io.branchtalk.discussions.infrastructure

import cats.Show
import io.branchtalk.discussions.model.{ Post, Vote }
import io.branchtalk.shared.infrastructure.DoobieSupport.{ *, given }
import io.branchtalk.shared.model.branchtalkLocale

object DoobieExtensions {

private given [A: Show]: Show[Array[A]] = _.map(_.show).mkString(", ")

@SuppressWarnings(Array("org.wartremover.warts.Throw"))
given postContentTypeMeta: Meta[Post.Content.Type] = pgEnumString(
"post_content_type",
name =>
Post.Content.Type.values
.find(_.entryName.equalsIgnoreCase(name))
.getOrElse(
throw new NoSuchElementException(
s"$name is not a member of Enum (${Post.Content.Type.values.mkString(", ")})"
)
),
.getOrElse(throw new NoSuchElementException(show"$name is not a member of Enum (${Post.Content.Type.values})")),
_.entryName.toLowerCase(branchtalkLocale)
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package io.branchtalk.api
import cats.arrow.FunctionK
import cats.data.NonEmptyList
import cats.effect.{ Async, Resource }
import fs2.compression.Compression
import io.branchtalk.auth.{ AuthServices, AuthServicesImpl }
import io.branchtalk.configs.{ APIConfig, APIPart, AppArguments, PaginationConfig }
import io.branchtalk.discussions.api.{ ChannelServer, CommentServer, PostServer, SubscriptionServer }
Expand Down Expand Up @@ -63,6 +64,8 @@ final class AppServer[F[_]: Async: MDC](
logAction = ((s: String) => logger.info(s)).some
)(_)

private given Compression[F] = Compression.forSync[F]

val routes: HttpApp[F] =
NonEmptyList
.of(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ final case class APIContact(
def toOpenAPI: Contact = Contact(
name = name.some,
email = email.unwrap.some,
url = url.unwrap.toString.some
url = url.show.some
)
}

Expand All @@ -39,7 +39,7 @@ final case class APILicense(

def toOpenAPI: License = License(
name = name,
url = url.unwrap.toString.some
url = url.show.some
)
}

Expand All @@ -57,7 +57,7 @@ final case class APIInfo(
title = title,
version = version,
description = description.some,
termsOfService = termsOfService.unwrap.toString.some,
termsOfService = termsOfService.show.some,
contact = contact.toOpenAPI.some,
license = license.toOpenAPI.some
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package io.branchtalk.users.infrastructure

import cats.Id
import cats.{ Id, Show }
import com.github.plokhotnyuk.jsoniter_scala.core.*
import com.github.plokhotnyuk.jsoniter_scala.macros.*
import io.branchtalk.shared.infrastructure.DoobieSupport.{ *, given }
Expand All @@ -13,14 +13,15 @@ import scala.collection.compat.immutable.ArraySeq

object DoobieExtensions {

private given [A: Show]: Show[Array[A]] = _.map(_.show).mkString(", ")

@SuppressWarnings(Array("org.wartremover.warts.Throw"))
given banScopeTypeMeta: Meta[Ban.Scope.Type] = pgEnumString(
"user_ban_type",
name =>
Ban.Scope.Type.values
.find(_.entryName.equalsIgnoreCase(name))
.getOrElse(
throw new NoSuchElementException(s"$name is not a member of Enum (${Ban.Scope.Type.values.mkString(", ")})")
),
.getOrElse(throw new NoSuchElementException(show"$name is not a member of Enum (${Ban.Scope.Type.values})")),
_.entryName.toLowerCase(branchtalkLocale)
)

Expand All @@ -34,31 +35,29 @@ object DoobieExtensions {

given passwordSaltMeta: Meta[Password.Salt] = Password.Salt.unsafeMakeF(Meta.apply)

@SuppressWarnings(Array("org.wartremover.warts.Throw"))
given sessionUsageTypeMeta: Meta[Session.Usage.Type] = pgEnumString(
"session_usage_type",
name =>
Session.Usage.Type.values
.find(_.entryName.equalsIgnoreCase(name))
.getOrElse(
throw new NoSuchElementException(
s"$name is not a member of Enum (${Session.Usage.Type.values.mkString(", ")})"
)
throw new NoSuchElementException(show"$name is not a member of Enum (${Session.Usage.Type.values})")
),
_.entryName.toLowerCase(branchtalkLocale)
)

given sessionExpirationTime: Meta[Session.ExpirationTime] = Session.ExpirationTime.unsafeMakeF(Meta.apply)

@SuppressWarnings(Array("org.wartremover.warts.Throw"))
given sensitiveDataAlgorithmTypeMeta: Meta[SensitiveData.Algorithm] =
pgEnumString(
"data_encryption_algorithm",
name =>
SensitiveData.Algorithm.values
.find(_.entryName.equalsIgnoreCase(name))
.getOrElse(
throw new NoSuchElementException(
s"$name is not a member of Enum (${SensitiveData.Algorithm.values.mkString(", ")})"
)
throw new NoSuchElementException(show"$name is not a member of Enum (${SensitiveData.Algorithm.values})")
),
_.entryName.toLowerCase(branchtalkLocale)
)
Expand Down

0 comments on commit 08724b3

Please sign in to comment.