Skip to content

Commit

Permalink
style: remove deprecated Scala syntax (#1134)
Browse files Browse the repository at this point in the history
Signed-off-by: FabioPinheiro <[email protected]>
  • Loading branch information
FabioPinheiro authored Jun 3, 2024
1 parent f719120 commit eedb6fd
Show file tree
Hide file tree
Showing 64 changed files with 157 additions and 158 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ private[castor] trait ProtoModelHelper {
case ServiceType.Single(name) => name.value
case ts: ServiceType.Multiple =>
val names = ts.values.map(_.value).map(Json.fromString)
Json.arr(names: _*).noSpaces
Json.arr(names*).noSpaces
}
}
}
Expand All @@ -210,7 +210,7 @@ private[castor] trait ProtoModelHelper {
case UriOrJsonEndpoint.Uri(uri) => Json.fromString(uri.value)
case UriOrJsonEndpoint.Json(json) => Json.fromJsonObject(json)
}
Json.arr(uris: _*).noSpaces
Json.arr(uris*).noSpaces
}
}
}
Expand Down Expand Up @@ -250,10 +250,10 @@ private[castor] trait ProtoModelHelper {
Clock.instant.map { now =>
didData
.withPublicKeys(didData.publicKeys.filter { publicKey =>
publicKey.revokedOn.flatMap(_.toInstant).forall(revokeTime => revokeTime isAfter now)
publicKey.revokedOn.flatMap(_.toInstant).forall(revokeTime => revokeTime `isAfter` now)
})
.withServices(didData.services.filter { service =>
service.deletedOn.flatMap(_.toInstant).forall(revokeTime => revokeTime isAfter now)
service.deletedOn.flatMap(_.toInstant).forall(revokeTime => revokeTime `isAfter` now)
})
}
}
Expand Down Expand Up @@ -370,7 +370,7 @@ private[castor] trait ProtoModelHelper {
case Nil => Left("the service type cannot be an empty JSON array")
}
.filterOrElse(
_ => s == io.circe.Json.arr(jsonArr: _*).noSpaces,
_ => s == io.circe.Json.arr(jsonArr*).noSpaces,
"the service type is a valid JSON array of strings, but not conform to the ABNF"
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ private[castor] trait W3CModelHelper {
case UriOrJsonEndpoint.Uri(uri) => Json.fromString(uri.value)
case UriOrJsonEndpoint.Json(json) => Json.fromJsonObject(json)
}
Json.arr(uris: _*)
Json.arr(uris*)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class WebhookPublisher(
} yield ()
}

private[this] def pollAndNotify[A](consumer: EventConsumer[A])(implicit encoder: JsonEncoder[A]) = {
private def pollAndNotify[A](consumer: EventConsumer[A])(implicit encoder: JsonEncoder[A]) = {
for {
_ <- ZIO.log(s"Polling $parallelism event(s)")
events <- consumer.poll(parallelism).mapError(e => UnexpectedError(e.toString))
Expand All @@ -80,7 +80,7 @@ class WebhookPublisher(
} yield ()
}

private[this] def generateNotifyWebhookTasks[A](
private def generateNotifyWebhookTasks[A](
event: Event[A],
webhooks: Seq[EventNotificationConfig]
)(implicit encoder: JsonEncoder[A]): Seq[ZIO[Client, UnexpectedError, Unit]] = {
Expand All @@ -94,7 +94,7 @@ class WebhookPublisher(
.map { case (url, headers) => notifyWebhook(event, url.toString, headers) }
}

private[this] def notifyWebhook[A](event: Event[A], url: String, headers: Headers)(implicit
private def notifyWebhook[A](event: Event[A], url: String, headers: Headers)(implicit
encoder: JsonEncoder[A]
): ZIO[Client, UnexpectedError, Unit] = {
val result = for {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ trait ControllerHelper {

protected case class DidIdPair(myDID: DidId, theirDid: DidId)

private[this] def extractDidIdPairFromEstablishedConnection(
private def extractDidIdPairFromEstablishedConnection(
record: ConnectionRecord
): IO[InvalidStateForOperation, DidIdPair] = {
(record.protocolState, record.connectionResponse, record.role) match {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ object ConnectBackgroundJobs extends BackgroundJobsHelper {
} yield ()
}

private[this] def performExchange(
private def performExchange(
record: ConnectionRecord
): URIO[
DidOps & DIDResolver & HttpClient & ConnectionService & ManagedDIDService & DIDNonSecretStorage & AppConfig,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ object IssueBackgroundJobs extends BackgroundJobsHelper {
.counterInt(key)
.fromConst(1)

private[this] def performIssueCredentialExchange(record: IssueCredentialRecord) = {
private def performIssueCredentialExchange(record: IssueCredentialRecord) = {
import IssueCredentialRecord.*
import IssueCredentialRecord.ProtocolState.*

Expand Down Expand Up @@ -634,8 +634,7 @@ object IssueBackgroundJobs extends BackgroundJobsHelper {

}

private[this] def handleCredentialErrors
: PartialFunction[Throwable | CredentialServiceError, CredentialServiceError] = {
private def handleCredentialErrors: PartialFunction[Throwable | CredentialServiceError, CredentialServiceError] = {
case e: CredentialServiceError => e
case t: Throwable => CredentialServiceError.UnexpectedError(t.getMessage())
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ object PresentBackgroundJobs extends BackgroundJobsHelper {
.counterInt(key)
.fromConst(1)

private[this] def createPrismDIDIssuerFromPresentationCredentials(
private def createPrismDIDIssuerFromPresentationCredentials(
presentationId: DidCommID,
credentialsToUse: Seq[String]
) =
Expand Down Expand Up @@ -104,7 +104,7 @@ object PresentBackgroundJobs extends BackgroundJobsHelper {

// Holder / Prover Get the Holder/Prover PrismDID from the IssuedCredential
// When holder accepts offer he provides the subjectdid
private[this] def getPrismDIDForHolderFromCredentials(
private def getPrismDIDForHolderFromCredentials(
presentationId: DidCommID,
credentialsToUse: Seq[String]
) =
Expand Down Expand Up @@ -139,7 +139,7 @@ object PresentBackgroundJobs extends BackgroundJobsHelper {
jwtIssuer <- getSDJwtIssuer(longFormPrismDID, VerificationRelationship.Authentication)
} yield jwtIssuer

private[this] def performPresentProofExchange(record: PresentationRecord): URIO[
private def performPresentProofExchange(record: PresentationRecord): URIO[
AppConfig & DidOps & DIDResolver & JwtDidResolver & HttpClient & PresentationService & CredentialService &
DIDNonSecretStorage & DIDService & ManagedDIDService,
Unit
Expand Down Expand Up @@ -1093,7 +1093,7 @@ object PresentBackgroundJobs extends BackgroundJobsHelper {

}

private[this] def handlePresentationErrors: PartialFunction[
private def handlePresentationErrors: PartialFunction[
Throwable | CredentialServiceError | PresentationError | BackgroundJobError,
PresentationError | CredentialServiceError | BackgroundJobError
] = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ final case class Migrations(config: DbConfig) {

object Migrations {
val layer: URLayer[DbConfig, Migrations] =
ZLayer.fromFunction(Migrations.apply _)
ZLayer.fromFunction(Migrations.apply)

/** Fail if the RLS is not enabled from a sample table */
def validateRLS: RIO[Transactor[ContextAwareTask], Unit] = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ object EndpointOutputs {
def basicFailuresWith(extraFailures: OneOfVariant[ErrorResponse]*) = {
oneOf(
FailureVariant.badRequest,
(FailureVariant.internalServerError +: extraFailures): _*
(FailureVariant.internalServerError +: extraFailures)*
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ class DIDCommControllerImpl(
} yield ()
}

private[this] def validateContentType(contentType: Option[String]) = {
private def validateContentType(contentType: Option[String]) = {
if (contentType.contains(MediaTypes.contentTypeEncrypted)) ZIO.unit
else ZIO.fail(InvalidContentType(contentType))
}

private[this] def handleMessage(msg: DIDCommMessage) = {
private def handleMessage(msg: DIDCommMessage) = {
ZIO.logAnnotate("request-id", UUID.randomUUID.toString) {
for {
msgAndContext <- unpackMessage(msg)
Expand All @@ -70,7 +70,7 @@ class DIDCommControllerImpl(
revocationNotification orElse
handleUnknownMessage

private[this] def unpackMessage(msg: DIDCommMessage): IO[DIDCommControllerError, (Message, WalletAccessContext)] =
private def unpackMessage(msg: DIDCommMessage): IO[DIDCommControllerError, (Message, WalletAccessContext)] =
for {
recipientDid <- ZIO
.fromOption(msg.recipients.headOption.map(_.header.kid.split("#")(0)))
Expand All @@ -92,7 +92,7 @@ class DIDCommControllerImpl(
/*
* Connect
*/
private[this] val handleConnect: PartialFunction[Message, ZIO[
private val handleConnect: PartialFunction[Message, ZIO[
WalletAccessContext,
DIDCommMessageParsingError | ConnectionServiceError,
Unit
Expand Down Expand Up @@ -122,7 +122,7 @@ class DIDCommControllerImpl(
/*
* Issue Credential
*/
private[this] val handleIssueCredential
private val handleIssueCredential
: PartialFunction[Message, ZIO[WalletAccessContext, CredentialServiceError, Unit]] = {
case msg if msg.piuri == OfferCredential.`type` =>
for {
Expand All @@ -147,7 +147,7 @@ class DIDCommControllerImpl(
/*
* Present Proof
*/
private[this] val handlePresentProof: PartialFunction[Message, ZIO[WalletAccessContext, PresentationError, Unit]] = {
private val handlePresentProof: PartialFunction[Message, ZIO[WalletAccessContext, PresentationError, Unit]] = {
case msg if msg.piuri == ProposePresentation.`type` =>
for {
proposePresentation <- ZIO.succeed(ProposePresentation.readFromMessage(msg))
Expand All @@ -168,7 +168,7 @@ class DIDCommControllerImpl(
} yield ()
}

private[this] val revocationNotification: PartialFunction[Message, ZIO[Any, Throwable, Unit]] = {
private val revocationNotification: PartialFunction[Message, ZIO[Any, Throwable, Unit]] = {
case msg if msg.piuri == RevocationNotification.`type` =>
for {
revocationNotification <- ZIO.attempt(RevocationNotification.readFromMessage(msg))
Expand All @@ -179,7 +179,7 @@ class DIDCommControllerImpl(
/*
* Unknown Message
*/
private[this] val handleUnknownMessage: PartialFunction[Message, UIO[String]] = { case _ =>
private val handleUnknownMessage: PartialFunction[Message, UIO[String]] = { case _ =>
ZIO.succeed("Unknown Message Type")
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ object SecurityLogic {
authenticator: Authenticator[E],
authorizer: Authorizer[E]
): IO[ErrorResponse, WalletAccessContext] =
authenticate[E](credentials, others: _*)(authenticator)
authenticate[E](credentials, others*)(authenticator)
.flatMap {
case Left(entity) => authorizeWalletAccess(entity)(EntityAuthorizer)
case Right(entity) => authorizeWalletAccess(entity)(authorizer)
Expand Down Expand Up @@ -79,7 +79,7 @@ object SecurityLogic {
def authorizeRole[E <: BaseEntity](credentials: Credentials, others: Credentials*)(
authenticator: Authenticator[E],
)(permittedRole: EntityRole): IO[ErrorResponse, BaseEntity] = {
authenticate[E](credentials, others: _*)(authenticator)
authenticate[E](credentials, others*)(authenticator)
.flatMap { ee =>
val entity = ee.fold(identity, identity)
for {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,15 +93,15 @@ class CredentialDefinitionControllerImpl(service: CredentialDefinitionService, m
} yield CredentialDefinitionControllerLogic(rc, pagination, page, stats).result
}

private[this] def validatePrismDID(author: String) =
private def validatePrismDID(author: String) =
for {
authorDID <- ZIO
.fromEither(PrismDID.fromString(author))
.mapError(_ => ErrorResponse.badRequest(detail = Some(s"Unable to parse as a Prism DID: ${author}")))
longFormPrismDID <- getLongForm(authorDID, true)
} yield longFormPrismDID

private[this] def getLongForm(
private def getLongForm(
did: PrismDID,
allowUnpublishedIssuingDID: Boolean = false
): ZIO[WalletAccessContext, ErrorResponse, LongFormPrismDID] = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,15 +108,15 @@ class CredentialSchemaControllerImpl(service: CredentialSchemaService, managedDI
} yield CredentialSchemaControllerLogic(rc, pagination, page, stats).result
}

private[this] def validatePrismDID(author: String) =
private def validatePrismDID(author: String) =
for {
authorDID <- ZIO
.fromEither(PrismDID.fromString(author))
.mapError(_ => ErrorResponse.badRequest(detail = Some(s"Unable to parse as a Prism DID: ${author}")))
longFormPrismDID <- getLongForm(authorDID, true)
} yield longFormPrismDID

private[this] def getLongForm(
private def getLongForm(
did: PrismDID,
allowUnpublishedIssuingDID: Boolean = false
): ZIO[WalletAccessContext, ErrorResponse, LongFormPrismDID] = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import scala.util.Using

object Tapir2StaticOAS extends ZIOAppDefault {

@main override def run: ZIO[Any with ZIOAppArgs with Scope, Any, Any] = {
@main override def run: ZIO[Any & ZIOAppArgs & Scope, Any, Any] = {
val effect = for {
args <- getArgs
_ <- ZIO.when(args.length != 2)(ZIO.fail("Usage: Tapir2StaticOAS <output file> <server url>"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ object MigrationAspects {
def migrate(schema: String, paths: String*): TestAspectAtLeastR[PostgreSQLContainer] = {
val migration = for {
pg <- ZIO.service[PostgreSQLContainer]
_ <- runMigration(pg.jdbcUrl, pg.username, pg.password, schema, paths: _*)
_ <- runMigration(pg.jdbcUrl, pg.username, pg.password, schema, paths*)
} yield ()

beforeAll(migration.orDie)
Expand All @@ -19,7 +19,7 @@ object MigrationAspects {
def migrateEach(schema: String, paths: String*): TestAspectAtLeastR[PostgreSQLContainer] = {
val migration = for {
pg <- ZIO.service[PostgreSQLContainer]
_ <- runMigration(pg.jdbcUrl, pg.username, pg.password, schema, paths: _*)
_ <- runMigration(pg.jdbcUrl, pg.username, pg.password, schema, paths*)
} yield ()

before(migration.orDie)
Expand All @@ -37,7 +37,7 @@ object MigrationAspects {
.configure()
.dataSource(url, username, password)
.schemas(schema)
.locations(locations: _*)
.locations(locations*)
.load()
.migrate()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ object ApiKeyAuthenticatorSpec extends ZIOSpecDefault, PostgresTestContainerSupp
pgContainerLayer
)

override def spec: Spec[TestEnvironment with Scope, Any] = {
override def spec: Spec[TestEnvironment & Scope, Any] = {
val testSuite = suite("ApiKeyAuthenticatorSpec")(
authenticationDisabledSpec,
authenticationEnabledSingleTenantSpec,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ object IssueControllerImplSpec extends ZIOSpecDefault with IssueControllerTestTo
None,
ConnectionRecord.Role.Inviter,
ConnectionRecord.ProtocolState.ConnectionResponseSent,
Invitation(from = DidId("did:peer:INVITER"), Invitation.Body(None, None, Nil)),
Invitation(from = DidId("did:peer:INVITER"), body = Invitation.Body(None, None, Nil)),
None,
Some(connectionResponse),
5,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ trait IssueControllerTestTools extends PostgresTestContainerSupport {
.load(AppConfig.config)
)

private[this] def makeResolver(lookup: Map[String, DIDDocument]): DidResolver = (didUrl: String) => {
private def makeResolver(lookup: Map[String, DIDDocument]): DidResolver = (didUrl: String) => {
lookup
.get(didUrl)
.fold(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ trait CredentialDefinitionTestTools extends PostgresTestContainerSupport {
}

trait CredentialDefinitionGen {
self: ZIOSpecDefault with CredentialDefinitionTestTools =>
self: ZIOSpecDefault & CredentialDefinitionTestTools =>
object Generator {
val credentialDefinitionName = Gen.alphaNumericStringBounded(4, 12)
val majorVersion = Gen.int(1, 9)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ trait CredentialSchemaTestTools extends PostgresTestContainerSupport {
}

trait CredentialSchemaGen {
self: ZIOSpecDefault with CredentialSchemaTestTools =>
self: ZIOSpecDefault & CredentialSchemaTestTools =>
object Generator {
val schemaName = Gen.alphaNumericStringBounded(4, 12)
val majorVersion = Gen.int(1, 9)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ trait VcVerificationControllerTestTools extends PostgresTestContainerSupport {

val didResolverLayer = ZLayer.fromZIO(ZIO.succeed(makeResolver(Map.empty)))

private[this] def makeResolver(lookup: Map[String, DIDDocument]): DidResolver = (didUrl: String) => {
private def makeResolver(lookup: Map[String, DIDDocument]): DidResolver = (didUrl: String) => {
lookup
.get(didUrl)
.fold(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ trait BaseEntity {
case class Entity(id: UUID, name: String, walletId: UUID, createdAt: Instant, updatedAt: Instant) extends BaseEntity {
def withUpdatedAt(updatedAt: Instant = Instant.now()): Entity = copy(updatedAt = updatedAt)
def withTruncatedTimestamp(unit: ChronoUnit = ChronoUnit.MICROS): Entity =
copy(createdAt = createdAt.truncatedTo(unit), updatedAt.truncatedTo(unit))
copy(createdAt = createdAt.truncatedTo(unit), updatedAt = updatedAt.truncatedTo(unit))

def role: Either[String, EntityRole] =
if (this == Entity.Admin) Right(EntityRole.Admin)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class JdbcWalletNonSecretStorage(xa: Transactor[ContextAwareTask]) extends Walle
walletIds match
case Nil => ZIO.succeed(Nil)
case head +: tail =>
val nel = NonEmptyList.of(head, tail: _*)
val nel = NonEmptyList.of(head, tail*)
val conditionFragment = Fragments.in(fr"wallet_id", nel)
val cxnIO =
sql"""
Expand Down
Loading

0 comments on commit eedb6fd

Please sign in to comment.