Skip to content

Commit

Permalink
Change Scala 2 syntax that can be replaced with Scala 3 when using -X…
Browse files Browse the repository at this point in the history
…source:3 use compatible scalafmt dialect
  • Loading branch information
seakayone committed Nov 10, 2023
1 parent a646177 commit ea99bce
Show file tree
Hide file tree
Showing 212 changed files with 634 additions and 930 deletions.
2 changes: 1 addition & 1 deletion .scalafmt.conf
@@ -1,5 +1,5 @@
version = "3.7.15"
runner.dialect = scala213
runner.dialect = Scala213Source3
maxColumn = 120
align.preset = most
align.multiline = false
Expand Down
4 changes: 3 additions & 1 deletion integration/src/test/scala/org/knora/sipi/SipiIT.scala
Expand Up @@ -318,7 +318,9 @@ object MockDspApiServer {
}

def resetAndGetWireMockServer: URIO[WireMockServer, WireMockServer] =
ZIO.serviceWith[WireMockServer] { it => it.resetAll(); it }
ZIO.serviceWith[WireMockServer] { it =>
it.resetAll(); it
}

def resetAndStubGetResponse(url: String, status: Int): URIO[WireMockServer, WireMockServer] =
resetAndGetWireMockServer.tap(server => ZIO.succeed(stubGetJsonResponse(server, url, status)))
Expand Down
Expand Up @@ -34,7 +34,9 @@ class CardinalitiesSpec extends CoreSpec {
_.isPropertyUsedInResources(internalClassIri, internalPropertyIri)
)
)
resF map { res => println(res); assert(res, "property is used in resource (instance of that resource class)") }
resF map { res =>
println(res); assert(res, "property is used in resource (instance of that resource class)")
}
}

"detect that property is not in use, when not used in a resource" in {
Expand Down Expand Up @@ -81,7 +83,9 @@ class CardinalitiesSpec extends CoreSpec {
_.isPropertyUsedInResources(internalClassIri, internalPropertyIri)
)
)
resF map { res => println(res); assert(res, "property is used in resource (instance of resource class)") }
resF map { res =>
println(res); assert(res, "property is used in resource (instance of resource class)")
}
}

"detect that property is in use, when used in a resource of a subclass" in {
Expand All @@ -93,7 +97,9 @@ class CardinalitiesSpec extends CoreSpec {
UnsafeZioRun.runToFuture(
ZIO.serviceWithZIO[CardinalityHandler](_.isPropertyUsedInResources(internalClassIri, internalPropertyIri))
)
resF map { res => println(res); assert(res, "property is used in a resource of subclass") }
resF map { res =>
println(res); assert(res, "property is used in a resource of subclass")
}
}
}
}
2 changes: 1 addition & 1 deletion webapi/src/main/scala/dsp/constants/SalsahGui.scala
Expand Up @@ -5,7 +5,7 @@

package dsp.constants

import dsp.errors._
import dsp.errors.*

/**
* Contains string constants for IRIs from ontologies used by the application.
Expand Down
4 changes: 2 additions & 2 deletions webapi/src/main/scala/dsp/valueobjects/User.scala
Expand Up @@ -7,12 +7,12 @@ package dsp.valueobjects

import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder
import org.springframework.security.crypto.scrypt.SCryptPasswordEncoder
import zio._
import zio.*
import zio.config.magnolia.Descriptor
import zio.json.JsonCodec
import zio.json.JsonDecoder
import zio.json.JsonEncoder
import zio.prelude.Assertion._
import zio.prelude.Assertion.*
import zio.prelude.Subtype
import zio.prelude.Validation

Expand Down
2 changes: 1 addition & 1 deletion webapi/src/main/scala/dsp/valueobjects/V2.scala
Expand Up @@ -5,7 +5,7 @@

package dsp.valueobjects

import zio.json._
import zio.json.*

object V2 {

Expand Down
6 changes: 3 additions & 3 deletions webapi/src/main/scala/org/knora/webapi/Main.scala
Expand Up @@ -5,9 +5,9 @@

package org.knora.webapi

import zio._
import zio.*

import org.knora.webapi.core._
import org.knora.webapi.core.*
import org.knora.webapi.slice.infrastructure.MetricsServer
import org.knora.webapi.util.Logger

Expand All @@ -30,6 +30,6 @@ object Main extends ZIOApp {
/**
* Entrypoint of our Application
*/
override def run: ZIO[Environment with ZIOAppArgs with Scope, Any, Any] =
override def run: ZIO[Environment & ZIOAppArgs & Scope, Any, Any] =
AppServer.make *> MetricsServer.make

Check warning on line 34 in webapi/src/main/scala/org/knora/webapi/Main.scala

View check run for this annotation

Codecov / codecov/patch

webapi/src/main/scala/org/knora/webapi/Main.scala#L34

Added line #L34 was not covered by tests
}
10 changes: 5 additions & 5 deletions webapi/src/main/scala/org/knora/webapi/config/AppConfig.scala
Expand Up @@ -6,10 +6,10 @@
package org.knora.webapi.config

import com.typesafe.config.ConfigFactory
import zio._
import zio.config._
import zio.config.magnolia._
import zio.config.typesafe._
import zio.*
import zio.config.*
import zio.config.magnolia.*
import zio.config.typesafe.*

import java.time.Duration

Expand Down Expand Up @@ -203,7 +203,7 @@ final case class InstrumentationServerConfig(
)

object AppConfig {
type AppConfigurations = AppConfig with JwtConfig with DspIngestConfig with Triplestore
type AppConfigurations = AppConfig & JwtConfig & DspIngestConfig & Triplestore

val layer: ULayer[AppConfigurations] = {
val appConfigLayer = ZLayer {
Expand Down
Expand Up @@ -6,7 +6,7 @@
package org.knora.webapi.core

import org.apache.pekko
import zio._
import zio.*
import zio.macros.accessible

import scala.concurrent.ExecutionContext
Expand Down
26 changes: 5 additions & 21 deletions webapi/src/main/scala/org/knora/webapi/core/AppRouter.scala
Expand Up @@ -6,7 +6,7 @@
package org.knora.webapi.core

import org.apache.pekko
import zio._
import zio.*
import zio.macros.accessible

import org.knora.webapi.core
Expand All @@ -32,17 +32,8 @@ trait AppRouter {

object AppRouter {
val layer: ZLayer[
core.ActorSystem
with CardinalityHandler
with CardinalityService
with ConstructResponseUtilV2
with MessageRelay
with OntologyCache
with OntologyHelpers
with OntologyRepo
with PermissionUtilADM
with ResourceUtilV2
with StandoffTagUtilV2,
core.ActorSystem & CardinalityHandler & CardinalityService & ConstructResponseUtilV2 & MessageRelay &
OntologyCache & OntologyHelpers & OntologyRepo & PermissionUtilADM & ResourceUtilV2 & StandoffTagUtilV2,
Nothing,
AppRouter
] =
Expand All @@ -52,15 +43,8 @@ object AppRouter {
messageRelay <- ZIO.service[MessageRelay]
runtime <-
ZIO.runtime[
CardinalityHandler
with CardinalityService
with ConstructResponseUtilV2
with OntologyCache
with OntologyHelpers
with OntologyRepo
with PermissionUtilADM
with ResourceUtilV2
with StandoffTagUtilV2
CardinalityHandler & CardinalityService & ConstructResponseUtilV2 & OntologyCache & OntologyHelpers &
OntologyRepo & PermissionUtilADM & ResourceUtilV2 & StandoffTagUtilV2
]
} yield new AppRouter {
implicit val system: org.apache.pekko.actor.ActorSystem = as.system
Expand Down
13 changes: 3 additions & 10 deletions webapi/src/main/scala/org/knora/webapi/core/AppServer.scala
Expand Up @@ -5,7 +5,7 @@

package org.knora.webapi.core

import zio._
import zio.*

import org.knora.webapi.config.AppConfig
import org.knora.webapi.core.domain.AppState
Expand Down Expand Up @@ -156,15 +156,8 @@ final case class AppServer(
object AppServer {

private type AppServerEnvironment =
State
with TriplestoreService
with RepositoryUpdater
with ActorSystem
with OntologyCache
with IIIFService
with CacheService
with HttpServer
with AppConfig
State & TriplestoreService & RepositoryUpdater & ActorSystem & OntologyCache & IIIFService & CacheService &
HttpServer & AppConfig

/**
* Initializes the AppServer instance with the required services
Expand Down
4 changes: 2 additions & 2 deletions webapi/src/main/scala/org/knora/webapi/core/HttpServer.scala
Expand Up @@ -6,7 +6,7 @@
package org.knora.webapi.core

import org.apache.pekko
import zio._
import zio.*

import org.knora.webapi.config.AppConfig
import org.knora.webapi.core
Expand All @@ -22,7 +22,7 @@ trait HttpServer {
}

object HttpServer {
val layer: ZLayer[ActorSystem with AppConfig with ApiRoutes, Nothing, HttpServer] =
val layer: ZLayer[ActorSystem & AppConfig & ApiRoutes, Nothing, HttpServer] =
ZLayer.scoped {
for {
as <- ZIO.service[core.ActorSystem]
Expand Down
81 changes: 18 additions & 63 deletions webapi/src/main/scala/org/knora/webapi/core/LayersLive.scala
Expand Up @@ -11,7 +11,7 @@ import zio.ZLayer
import org.knora.webapi.config.AppConfig
import org.knora.webapi.config.AppConfig.AppConfigurations
import org.knora.webapi.messages.StringFormatter
import org.knora.webapi.messages.util._
import org.knora.webapi.messages.util.*
import org.knora.webapi.messages.util.search.QueryTraverser
import org.knora.webapi.messages.util.search.gravsearch.prequery.InferenceOptimizationService
import org.knora.webapi.messages.util.search.gravsearch.transformers.ConstructTransformer
Expand All @@ -20,20 +20,20 @@ import org.knora.webapi.messages.util.search.gravsearch.types.GravsearchTypeInsp
import org.knora.webapi.messages.util.standoff.StandoffTagUtilV2
import org.knora.webapi.messages.util.standoff.StandoffTagUtilV2Live
import org.knora.webapi.responders.IriService
import org.knora.webapi.responders.admin._
import org.knora.webapi.responders.v2._
import org.knora.webapi.responders.admin.*
import org.knora.webapi.responders.v2.*
import org.knora.webapi.responders.v2.ontology.CardinalityHandler
import org.knora.webapi.responders.v2.ontology.CardinalityHandlerLive
import org.knora.webapi.responders.v2.ontology.OntologyHelpers
import org.knora.webapi.responders.v2.ontology.OntologyHelpersLive
import org.knora.webapi.routing._
import org.knora.webapi.slice.admin.api._
import org.knora.webapi.routing.*
import org.knora.webapi.slice.admin.api.*
import org.knora.webapi.slice.admin.api.service.MaintenanceRestService
import org.knora.webapi.slice.admin.api.service.ProjectADMRestService
import org.knora.webapi.slice.admin.api.service.ProjectsADMRestServiceLive
import org.knora.webapi.slice.admin.domain.service._
import org.knora.webapi.slice.admin.domain.service.*
import org.knora.webapi.slice.admin.repo.service.KnoraProjectRepoLive
import org.knora.webapi.slice.common.api._
import org.knora.webapi.slice.common.api.*
import org.knora.webapi.slice.common.repo.service.PredicateObjectMapper
import org.knora.webapi.slice.ontology.api.service.RestCardinalityService
import org.knora.webapi.slice.ontology.api.service.RestCardinalityServiceLive
Expand Down Expand Up @@ -65,62 +65,17 @@ object LayersLive {
* The `Environment` that we require to exist at startup.
*/
type DspEnvironmentLive =
ActorSystem
with ApiRoutes
with AppConfigurations
with AppRouter
with Authenticator
with CacheService
with CacheServiceRequestMessageHandler
with CardinalityHandler
with CardinalityService
with ConstructResponseUtilV2
with ConstructTransformer
with GravsearchTypeInspectionRunner
with GroupsResponderADM
with HttpServer
with IIIFRequestMessageHandler
with IIIFService
with InferenceOptimizationService
with IriService
with IriConverter
with JwtService
with KnoraProjectRepo
with ListsResponderADM
with ListsResponderV2
with MessageRelay
with OntologyCache
with OntologyHelpers
with OntologyRepo
with OntologyResponderV2
with PermissionUtilADM
with PermissionsResponderADM
with PredicateObjectMapper
with ProjectADMRestService
with ProjectADMService
with ProjectExportService
with ProjectExportStorageService
with ProjectImportService
with ProjectsResponderADM
with QueryTraverser
with RepositoryUpdater
with ResourceUtilV2
with ResourceUtilV2
with ResourcesResponderV2
with RestCardinalityService
with RestPermissionService
with RestResourceInfoService
with SearchResponderV2
with SipiResponderADM
with OntologyInferencer
with StandoffResponderV2
with StandoffTagUtilV2
with State
with StoresResponderADM
with StringFormatter
with TriplestoreService
with UsersResponderADM
with ValuesResponderV2
ActorSystem & ApiRoutes & AppConfigurations & AppRouter & Authenticator & CacheService &
CacheServiceRequestMessageHandler & CardinalityHandler & CardinalityService & ConstructResponseUtilV2 &
ConstructTransformer & GravsearchTypeInspectionRunner & GroupsResponderADM & HttpServer &
IIIFRequestMessageHandler & IIIFService & InferenceOptimizationService & IriService & IriConverter & JwtService &
KnoraProjectRepo & ListsResponderADM & ListsResponderV2 & MessageRelay & OntologyCache & OntologyHelpers &
OntologyRepo & OntologyResponderV2 & PermissionUtilADM & PermissionsResponderADM & PredicateObjectMapper &
ProjectADMRestService & ProjectADMService & ProjectExportService & ProjectExportStorageService &
ProjectImportService & ProjectsResponderADM & QueryTraverser & RepositoryUpdater & ResourceUtilV2 &
ResourceUtilV2 & ResourcesResponderV2 & RestCardinalityService & RestPermissionService & RestResourceInfoService &
SearchResponderV2 & SipiResponderADM & OntologyInferencer & StandoffResponderV2 & StandoffTagUtilV2 & State &
StoresResponderADM & StringFormatter & TriplestoreService & UsersResponderADM & ValuesResponderV2

/**
* All effect layers needed to provide the `Environment`
Expand Down
Expand Up @@ -5,7 +5,7 @@

package org.knora.webapi.core

import zio._
import zio.*
import zio.macros.accessible

import org.knora.webapi.messages.ResponderRequest
Expand Down
2 changes: 1 addition & 1 deletion webapi/src/main/scala/org/knora/webapi/core/State.scala
Expand Up @@ -5,7 +5,7 @@

package org.knora.webapi.core

import zio._
import zio.*
import zio.macros.accessible

import org.knora.webapi.core.domain.AppState
Expand Down
Expand Up @@ -6,15 +6,15 @@
package org.knora.webapi.core.actors

import org.apache.pekko
import zio._
import zio.*

import dsp.errors.UnexpectedMessageException
import org.knora.webapi.core.MessageRelay
import org.knora.webapi.core.RelayedMessage
import org.knora.webapi.messages.util.ConstructResponseUtilV2
import org.knora.webapi.messages.util.PermissionUtilADM
import org.knora.webapi.messages.util.standoff.StandoffTagUtilV2
import org.knora.webapi.responders.v2._
import org.knora.webapi.responders.v2.*
import org.knora.webapi.responders.v2.ontology.CardinalityHandler
import org.knora.webapi.responders.v2.ontology.OntologyHelpers
import org.knora.webapi.slice.ontology.domain.service.CardinalityService
Expand All @@ -27,15 +27,8 @@ import pekko.actor.Actor
final case class RoutingActor(
messageRelay: MessageRelay,
implicit val runtime: Runtime[
CardinalityHandler
with CardinalityService
with ConstructResponseUtilV2
with OntologyCache
with OntologyHelpers
with OntologyRepo
with PermissionUtilADM
with ResourceUtilV2
with StandoffTagUtilV2
CardinalityHandler & CardinalityService & ConstructResponseUtilV2 & OntologyCache & OntologyHelpers & OntologyRepo &
PermissionUtilADM & ResourceUtilV2 & StandoffTagUtilV2
]
) extends Actor {
def receive: Receive = {
Expand Down

0 comments on commit ea99bce

Please sign in to comment.