Skip to content

Commit

Permalink
CORE-126: Enable scalafmt and format all source code (#1468)
Browse files Browse the repository at this point in the history
  • Loading branch information
davidangb authored Oct 25, 2024
1 parent 2974439 commit 3686bb4
Show file tree
Hide file tree
Showing 202 changed files with 10,301 additions and 6,125 deletions.
17 changes: 17 additions & 0 deletions .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
version = 3.8.3
align = none
align.openParenCallSite = true
align.openParenDefnSite = true
maxColumn = 120
continuationIndent.defnSite = 2
assumeStandardLibraryStripMargin = true
danglingParentheses.preset = true
rewrite.rules = [SortImports, RedundantBraces, RedundantParens, SortModifiers]
docstrings.style = keep
project.excludeFilters = [
Dependencies.scala,
Settings.scala,
build.sbt
]
runner.dialect = scala213
project.git = true
2 changes: 2 additions & 0 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@ addSbtPlugin("io.spray" % "sbt-revolver" % "0.10.0")

addSbtPlugin("org.scoverage" % "sbt-scoverage" % "2.2.1")

addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.5.2")

addDependencyTreePlugin
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ case class Application(agoraDAO: AgoraDAO,
shareLogDAO: ShareLogDAO,
shibbolethDAO: ShibbolethDAO,
cwdsDAO: CwdsDAO,
ecmDAO: ExternalCredsDAO)
ecmDAO: ExternalCredsDAO
)
86 changes: 62 additions & 24 deletions src/main/scala/org/broadinstitute/dsde/firecloud/Boot.scala
Original file line number Diff line number Diff line change
Expand Up @@ -27,24 +27,28 @@ object Boot extends App with LazyLogging {

val app: Application = buildApplication

val agoraPermissionServiceConstructor: (UserInfo) => AgoraPermissionService = AgoraPermissionService.constructor(app)
val exportEntitiesByTypeActorConstructor: (ExportEntitiesByTypeArguments) => ExportEntitiesByTypeActor = ExportEntitiesByTypeActor.constructor(app, system)
val agoraPermissionServiceConstructor: (UserInfo) => AgoraPermissionService =
AgoraPermissionService.constructor(app)
val exportEntitiesByTypeActorConstructor: (ExportEntitiesByTypeArguments) => ExportEntitiesByTypeActor =
ExportEntitiesByTypeActor.constructor(app, system)
val entityServiceConstructor: (ModelSchema) => EntityService = EntityService.constructor(app)
val libraryServiceConstructor: (UserInfo) => LibraryService = LibraryService.constructor(app)
val ontologyServiceConstructor: () => OntologyService = OntologyService.constructor(app)
val namespaceServiceConstructor: (UserInfo) => NamespaceService = NamespaceService.constructor(app)
val nihServiceConstructor: () => NihService = NihService.constructor(app)
val registerServiceConstructor: () => RegisterService = RegisterService.constructor(app)
val workspaceServiceConstructor: (WithAccessToken) => WorkspaceService = WorkspaceService.constructor(app)
val permissionReportServiceConstructor: (UserInfo) => PermissionReportService = PermissionReportService.constructor(app)
val permissionReportServiceConstructor: (UserInfo) => PermissionReportService =
PermissionReportService.constructor(app)
val userServiceConstructor: (UserInfo) => UserService = UserService.constructor(app)
val shareLogServiceConstructor: () => ShareLogService = ShareLogService.constructor(app)
val managedGroupServiceConstructor: (WithAccessToken) => ManagedGroupService = ManagedGroupService.constructor(app)

//Boot HealthMonitor actor
// Boot HealthMonitor actor
val healthChecks = new HealthChecks(app)
val healthMonitorChecks = healthChecks.healthMonitorChecks
val healthMonitor = system.actorOf(HealthMonitor.props(healthMonitorChecks().keySet)( healthMonitorChecks ), "health-monitor")
val healthMonitor =
system.actorOf(HealthMonitor.props(healthMonitorChecks().keySet)(healthMonitorChecks), "health-monitor")
system.scheduler.scheduleWithFixedDelay(3.seconds, 1.minute, healthMonitor, HealthMonitor.CheckAll)

val statusServiceConstructor: () => StatusService = StatusService.constructor(healthMonitor)
Expand Down Expand Up @@ -77,50 +81,84 @@ object Boot extends App with LazyLogging {
)
}

binding <- Http().newServerAt( "0.0.0.0", 8080).bind(service.route)
binding <- Http().newServerAt("0.0.0.0", 8080).bind(service.route)
_ <- binding.whenTerminated

} yield {
} yield {}

}

runningService.recover {
case t: Throwable => logger.error("FATAL - error starting Firecloud Orchestration", t)
}.flatMap(_ => system.terminate())
runningService
.recover { case t: Throwable =>
logger.error("FATAL - error starting Firecloud Orchestration", t)
}
.flatMap(_ => system.terminate())
}

private def buildApplication(implicit system: ActorSystem) = {
// can't be disabled
val rawlsDAO: RawlsDAO = new HttpRawlsDAO
val samDAO: SamDAO = new HttpSamDAO
val thurloeDAO: ThurloeDAO = new HttpThurloeDAO
val ecmDAO: ExternalCredsDAO = if (FireCloudConfig.ExternalCreds.enabled) new HttpExternalCredsDAO else new DisabledExternalCredsDAO
val ecmDAO: ExternalCredsDAO =
if (FireCloudConfig.ExternalCreds.enabled) new HttpExternalCredsDAO else new DisabledExternalCredsDAO

// can be disabled
val agoraDAO: AgoraDAO = whenEnabled[AgoraDAO](FireCloudConfig.Agora.enabled, new HttpAgoraDAO(FireCloudConfig.Agora))
val googleServicesDAO: GoogleServicesDAO = whenEnabled[GoogleServicesDAO](FireCloudConfig.GoogleCloud.enabled, new HttpGoogleServicesDAO(FireCloudConfig.GoogleCloud.priceListUrl, GooglePriceList(GooglePrices(FireCloudConfig.GoogleCloud.defaultStoragePriceList, UsTieredPriceItem(FireCloudConfig.GoogleCloud.defaultEgressPriceList)), "v1", "1")))
val shibbolethDAO: ShibbolethDAO = whenEnabled[ShibbolethDAO](FireCloudConfig.Shibboleth.enabled, new HttpShibbolethDAO)
val cwdsDAO: CwdsDAO = whenEnabled[CwdsDAO](FireCloudConfig.Cwds.enabled, new HttpCwdsDAO(FireCloudConfig.Cwds.enabled, FireCloudConfig.Cwds.supportedFormats))
val agoraDAO: AgoraDAO =
whenEnabled[AgoraDAO](FireCloudConfig.Agora.enabled, new HttpAgoraDAO(FireCloudConfig.Agora))
val googleServicesDAO: GoogleServicesDAO = whenEnabled[GoogleServicesDAO](
FireCloudConfig.GoogleCloud.enabled,
new HttpGoogleServicesDAO(
FireCloudConfig.GoogleCloud.priceListUrl,
GooglePriceList(GooglePrices(FireCloudConfig.GoogleCloud.defaultStoragePriceList,
UsTieredPriceItem(FireCloudConfig.GoogleCloud.defaultEgressPriceList)
),
"v1",
"1"
)
)
)
val shibbolethDAO: ShibbolethDAO =
whenEnabled[ShibbolethDAO](FireCloudConfig.Shibboleth.enabled, new HttpShibbolethDAO)
val cwdsDAO: CwdsDAO = whenEnabled[CwdsDAO](
FireCloudConfig.Cwds.enabled,
new HttpCwdsDAO(FireCloudConfig.Cwds.enabled, FireCloudConfig.Cwds.supportedFormats)
)

val elasticSearchClient: Option[TransportClient] = Option.when(FireCloudConfig.ElasticSearch.enabled) {
ElasticUtils.buildClient(FireCloudConfig.ElasticSearch.servers, FireCloudConfig.ElasticSearch.clusterName)
}

val ontologyDAO: OntologyDAO = elasticSearchClient.map(new ElasticSearchOntologyDAO(_, FireCloudConfig.ElasticSearch.ontologyIndexName)).getOrElse(DisabledServiceFactory.newDisabledService[OntologyDAO])
val ontologyDAO: OntologyDAO = elasticSearchClient
.map(new ElasticSearchOntologyDAO(_, FireCloudConfig.ElasticSearch.ontologyIndexName))
.getOrElse(DisabledServiceFactory.newDisabledService[OntologyDAO])
val researchPurposeSupport: ResearchPurposeSupport = new ESResearchPurposeSupport(ontologyDAO)
val searchDAO: SearchDAO = elasticSearchClient.map(new ElasticSearchDAO(_, FireCloudConfig.ElasticSearch.indexName, researchPurposeSupport)).getOrElse(DisabledServiceFactory.newDisabledService[SearchDAO])
val shareLogDAO: ShareLogDAO = elasticSearchClient.map(new ElasticSearchShareLogDAO(_, FireCloudConfig.ElasticSearch.shareLogIndexName)).getOrElse(DisabledServiceFactory.newDisabledService[ShareLogDAO])

Application(agoraDAO, googleServicesDAO, ontologyDAO, rawlsDAO, samDAO, searchDAO, researchPurposeSupport, thurloeDAO, shareLogDAO, shibbolethDAO, cwdsDAO, ecmDAO)
val searchDAO: SearchDAO = elasticSearchClient
.map(new ElasticSearchDAO(_, FireCloudConfig.ElasticSearch.indexName, researchPurposeSupport))
.getOrElse(DisabledServiceFactory.newDisabledService[SearchDAO])
val shareLogDAO: ShareLogDAO = elasticSearchClient
.map(new ElasticSearchShareLogDAO(_, FireCloudConfig.ElasticSearch.shareLogIndexName))
.getOrElse(DisabledServiceFactory.newDisabledService[ShareLogDAO])

Application(agoraDAO,
googleServicesDAO,
ontologyDAO,
rawlsDAO,
samDAO,
searchDAO,
researchPurposeSupport,
thurloeDAO,
shareLogDAO,
shibbolethDAO,
cwdsDAO,
ecmDAO
)
}

private def whenEnabled[T : ClassTag](enabled: Boolean, realService: => T): T = {
private def whenEnabled[T: ClassTag](enabled: Boolean, realService: => T): T =
if (enabled) {
realService
} else {
DisabledServiceFactory.newDisabledService
}
}

startup()
}
Loading

0 comments on commit 3686bb4

Please sign in to comment.