Skip to content

Commit 5e4e914

Browse files
refactor(formatting-logging): reformat scala code and change logging policy (DEV-839) (#2051)
* refactor: reduce logging noise * refactor(scalafmt): align.preset most instead of some
1 parent 0389e52 commit 5e4e914

258 files changed

Lines changed: 16816 additions & 15711 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.scalafmt.conf‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
version = "2.7.5"
22
maxColumn = 120
3-
align.preset = some
3+
align.preset = most
44
align.multiline = false
55
continuationIndent.defnSite = 2
66
assumeStandardLibraryStripMargin = true

‎build.sbt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ lazy val webapi: Project = Project(id = "webapi", base = file("webapi"))
138138
}, // allows sbt-javaagent to work with sbt-revolver
139139
reStart / javaOptions ++= webapiJavaRunOptions,
140140
javaAgents += Dependencies.aspectjweaver,
141-
fork := true, // run tests in a forked JVM
141+
fork := true, // run tests in a forked JVM
142142
Test / testForkedParallel := false, // run forked tests in parallel
143143
Test / parallelExecution := false, // run non-forked tests in parallel
144144
// Global / concurrentRestrictions += Tags.limit(Tags.Test, 1), // restrict the number of concurrently executing tests in all projects

‎dsp-api-main/src/main/scala/dsp/api/main/MainApp.scala‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ object MainApp extends ZIOAppDefault {
88
val effect: ZIO[Console with SchemaRepo, Nothing, Unit] =
99
for {
1010
profile <- SchemaRepo.lookup("user1").orDie
11-
_ <- printLine(profile).orDie
12-
_ <- printLine(42).orDie
11+
_ <- printLine(profile).orDie
12+
_ <- printLine(42).orDie
1313
} yield ()
1414

1515
val mainApp: ZIO[Any, Nothing, Unit] = effect.provide(Console.live ++ SchemaRepoLive.layer)
16-
def run: ZIO[Any, Nothing, Unit] = mainApp
16+
def run: ZIO[Any, Nothing, Unit] = mainApp
1717
}

‎project/plugins.sbt‎

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,27 @@ resolvers ++= Seq(
66
addDependencyTreePlugin
77

88
// Knora
9-
addSbtPlugin("com.typesafe.sbt" % "sbt-git" % "1.0.2")
10-
addSbtPlugin("com.github.sbt" % "sbt-native-packager" % "1.9.9")
11-
addSbtPlugin("io.kamon" % "sbt-aspectj-runner" % "1.1.1")
9+
addSbtPlugin("com.typesafe.sbt" % "sbt-git" % "1.0.2")
10+
addSbtPlugin("com.github.sbt" % "sbt-native-packager" % "1.9.9")
11+
addSbtPlugin("io.kamon" % "sbt-aspectj-runner" % "1.1.1")
1212

1313
// webapi
14-
addSbtPlugin("io.spray" % "sbt-revolver" % "0.9.1")
15-
addSbtPlugin("com.typesafe.sbt" % "sbt-twirl" % "1.5.1")
16-
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.14.10")
17-
addSbtPlugin("com.lightbend.sbt" % "sbt-javaagent" % "0.1.5")
18-
addSbtPlugin("io.gatling" % "gatling-sbt" % "2.2.2")
19-
addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.6.1")
20-
addSbtPlugin("com.codacy" % "sbt-codacy-coverage" % "1.3.15")
21-
addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.11.0")
14+
addSbtPlugin("io.spray" % "sbt-revolver" % "0.9.1")
15+
addSbtPlugin("com.typesafe.sbt" % "sbt-twirl" % "1.5.1")
16+
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.14.10")
17+
addSbtPlugin("com.lightbend.sbt" % "sbt-javaagent" % "0.1.5")
18+
addSbtPlugin("io.gatling" % "gatling-sbt" % "2.2.2")
19+
addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.6.1")
20+
addSbtPlugin("com.codacy" % "sbt-codacy-coverage" % "1.3.15")
21+
addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.11.0")
2222

2323
// ad-hoc plugins - uncomment on demenad and keep it commented out in main branch
24+
2425
// https://github.com/rtimush/sbt-updates
2526
// addSbtPlugin("com.timushev.sbt" % "sbt-updates" % "0.6.1")
27+
2628
// https://github.com/cb372/sbt-explicit-dependencies
2729
// addSbtPlugin("com.github.cb372" % "sbt-explicit-dependencies" % "0.2.16")
30+
31+
// https://scalameta.org/scalafmt/docs/installation.html#sbt
32+
// addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.6")

‎webapi/src/main/scala/org/knora/webapi/config/AppConfig.scala‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import zio.config._
77
import typesafe._
88
import magnolia._
99

10-
1110
final case class AppConfig(cacheService: CacheServiceConfig)
1211

1312
object AppConfig {

‎webapi/src/main/scala/org/knora/webapi/contributors/GenerateContributorsFile.scala‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@ object GenerateContributorsFile extends App {
2323

2424
// Configuration
2525

26-
val contributorsUrl = "https://api.github.com/repos/dasch-swiss/knora-api/contributors"
26+
val contributorsUrl = "https://api.github.com/repos/dasch-swiss/knora-api/contributors"
2727
val defaultOutputFile = "Contributors.md"
2828

2929
// Command-line args
3030

31-
private val conf = new GenerateContributorsFileConf(args.toIndexedSeq)
32-
private val token = conf.token.toOption
31+
private val conf = new GenerateContributorsFileConf(args.toIndexedSeq)
32+
private val token = conf.token.toOption
3333
private val outputFile: Path = Paths.get(conf.output())
3434

3535
// Get the list of contributors.

‎webapi/src/main/scala/org/knora/webapi/exceptions/Exceptions.scala‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ object InconsistentRepositoryDataException {
355355
}
356356

357357
case class MissingLastModificationDateOntologyException(message: String, cause: Option[Throwable] = None)
358-
extends InternalServerException(message, cause)
358+
extends InternalServerException(message, cause)
359359

360360
/**
361361
* Indicates that the API server generated invalid JSON in an API response.

‎webapi/src/main/scala/org/knora/webapi/feature/FeatureFactory.scala‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,13 +118,13 @@ object FeatureToggle {
118118
/**
119119
* The name of the HTTP request header containing feature toggles.
120120
*/
121-
val REQUEST_HEADER: String = "X-Knora-Feature-Toggles"
121+
val REQUEST_HEADER: String = "X-Knora-Feature-Toggles"
122122
val REQUEST_HEADER_LOWERCASE: String = REQUEST_HEADER.toLowerCase
123123

124124
/**
125125
* The name of the HTTP response header that lists configured feature toggles.
126126
*/
127-
val RESPONSE_HEADER: String = REQUEST_HEADER
127+
val RESPONSE_HEADER: String = REQUEST_HEADER
128128
val RESPONSE_HEADER_LOWERCASE: String = REQUEST_HEADER_LOWERCASE
129129

130130
/**
@@ -369,7 +369,7 @@ class RequestContextFeatureFactoryConfig(requestContext: RequestContext, parent:
369369
headerValueItem.split('=').map(_.trim) match {
370370
case Array(featureNameAndVersionStr: String, isEnabledStr: String) =>
371371
val featureNameAndVersion: Array[String] = featureNameAndVersionStr.split(':').map(_.trim)
372-
val featureName: String = featureNameAndVersion.head
372+
val featureName: String = featureNameAndVersion.head
373373

374374
// Accept the boolean values that are accepted in application.conf.
375375
val isEnabled: Boolean = if (TRUE_STRINGS.contains(isEnabledStr.toLowerCase)) {

‎webapi/src/main/scala/org/knora/webapi/http/handler/KnoraExceptionHandler.scala‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ object KnoraExceptionHandler extends LazyLogging {
110110

111111
val responseFields: Map[String, JsValue] = Map(
112112
"status" -> JsNumber(apiStatus.id),
113-
"error" -> JsString(makeClientErrorMessage(ex, settings))
113+
"error" -> JsString(makeClientErrorMessage(ex, settings))
114114
) ++ maybeAccess
115115

116116
HttpResponse(

‎webapi/src/main/scala/org/knora/webapi/http/status/ApiStatusCodesV1.scala‎

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -13,39 +13,39 @@ import org.knora.webapi.exceptions._
1313
* Based on `salsah/api/ApiErrors.php`.
1414
*/
1515
object ApiStatusCodesV1 extends Enumeration {
16-
val OK = Value(0)
17-
val INVALID_REQUEST_METHOD = Value(1)
18-
val CREDENTIALS_NOT_VALID = Value(2)
16+
val OK = Value(0)
17+
val INVALID_REQUEST_METHOD = Value(1)
18+
val CREDENTIALS_NOT_VALID = Value(2)
1919
val NO_RIGHTS_FOR_OPERATION = Value(3)
20-
val INTERNAL_SALSAH_ERROR = Value(4)
21-
val NO_PROPERTIES = Value(5)
22-
val NOT_IN_USERDATA = Value(6)
23-
val RESOURCE_ID_MISSING = Value(7)
24-
val UNKNOWN_VOCABULARY = Value(8)
20+
val INTERNAL_SALSAH_ERROR = Value(4)
21+
val NO_PROPERTIES = Value(5)
22+
val NOT_IN_USERDATA = Value(6)
23+
val RESOURCE_ID_MISSING = Value(7)
24+
val UNKNOWN_VOCABULARY = Value(8)
2525

2626
/**
2727
* The requested item was not found. This was called NO_NODES_FOUND in SALSAH; its meaning has been broadened here.
2828
*/
2929
val NOT_FOUND = Value(9)
3030

31-
val API_ENDPOINT_NOT_FOUND = Value(10)
32-
val INVALID_REQUEST_TYPE = Value(11)
33-
val PROPERTY_ID_MISSING = Value(12)
34-
val NOT_YET_IMPLEMENTED = Value(13)
35-
val COULD_NOT_OPEN_PROGRESS_FILE = Value(14)
31+
val API_ENDPOINT_NOT_FOUND = Value(10)
32+
val INVALID_REQUEST_TYPE = Value(11)
33+
val PROPERTY_ID_MISSING = Value(12)
34+
val NOT_YET_IMPLEMENTED = Value(13)
35+
val COULD_NOT_OPEN_PROGRESS_FILE = Value(14)
3636
val VALUE_ID_OR_RESTYPE_ID_MISSING = Value(15)
3737

3838
val HLIST_ALREADY_EXISTENT = Value(16)
39-
val HLIST_NO_LABELS = Value(17)
40-
val HLIST_NOT_EXISTING = Value(18)
41-
val HLIST_NO_POSITION = Value(19)
39+
val HLIST_NO_LABELS = Value(17)
40+
val HLIST_NOT_EXISTING = Value(18)
41+
val HLIST_NO_POSITION = Value(19)
4242
val HLIST_INVALID_POSITION = Value(20)
4343

44-
val SELECTION_NO_LABELS = Value(21)
45-
val SELECTION_ALREADY_EXISTENT = Value(22)
44+
val SELECTION_NO_LABELS = Value(21)
45+
val SELECTION_ALREADY_EXISTENT = Value(22)
4646
val SELECTION_MISSING_OR_INVALID_POSITION = Value(23)
47-
val SELECTION_DELETE_FAILED = Value(24)
48-
val SELECTION_NODE_ALREADY_EXISTENT = Value(25)
47+
val SELECTION_DELETE_FAILED = Value(24)
48+
val SELECTION_NODE_ALREADY_EXISTENT = Value(25)
4949

5050
val GEONAMES_GEONAME_ID_EXISTING = Value(26)
5151

0 commit comments

Comments
 (0)