Skip to content

Commit fd21430

Browse files
committed
Spotless code style changes
JAVA-4181
1 parent e9584dd commit fd21430

File tree

26 files changed

+260
-219
lines changed

26 files changed

+260
-219
lines changed

bson-scala/src/main/scala-2.13+/org/mongodb/scala/bson/collection/mutable/Document.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ case class Document(protected[scala] val underlying: BsonDocument)
140140
@inline final def ++(suffix: IterableOnce[(String, BsonValue)]): Document = concat(suffix)
141141
// scalastyle:on method.name
142142
def map[B](f: ((String, BsonValue)) => (String, BsonValue)): Document = strictOptimizedMap(newSpecificBuilder, f)
143-
//TODO other operations
143+
// TODO other operations
144144

145145
// scalastyle:off method.name
146146
/**

bson-scala/src/main/scala/org/mongodb/scala/bson/codecs/macrocodecs/CaseClassCodec.scala

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -127,18 +127,15 @@ private[codecs] object CaseClassCodec {
127127

128128
val fields: Map[Type, List[(TermName, Type)]] = {
129129
knownTypes
130-
.map(
131-
t =>
132-
(
133-
t,
134-
t.members.sorted
135-
.filter(_.isMethod)
136-
.map(_.asMethod)
137-
.filter(m => m.isGetter && m.isParamAccessor)
138-
.map(
139-
m => (m.name, m.returnType.asSeenFrom(t, t.typeSymbol))
140-
)
141-
)
130+
.map(t =>
131+
(
132+
t,
133+
t.members.sorted
134+
.filter(_.isMethod)
135+
.map(_.asMethod)
136+
.filter(m => m.isGetter && m.isParamAccessor)
137+
.map(m => (m.name, m.returnType.asSeenFrom(t, t.typeSymbol)))
138+
)
142139
)
143140
.toMap
144141
}
@@ -242,8 +239,8 @@ private[codecs] object CaseClassCodec {
242239
q"""
243240
typeArgs += ($key -> {
244241
val tpeArgs = mutable.ListBuffer.empty[Class[_]]
245-
..${flattenTypeArgs(f).map(
246-
t => q"tpeArgs += classOf[${if (isCaseClass(t)) t.finalResultType else t.finalResultType.erasure}]"
242+
..${flattenTypeArgs(f).map(t =>
243+
q"tpeArgs += classOf[${if (isCaseClass(t)) t.finalResultType else t.finalResultType.erasure}]"
247244
)}
248245
tpeArgs.toList
249246
})"""
@@ -293,11 +290,10 @@ private[codecs] object CaseClassCodec {
293290
*/
294291
def classToCaseClassMap = {
295292
val flattenedFieldTypes = fields.flatMap({ case (t, types) => types.map(f => f._2) :+ t })
296-
val setClassToCaseClassMap = flattenedFieldTypes.map(
297-
t =>
298-
q"""classToCaseClassMap ++= ${flattenTypeArgs(t).map(
299-
t => q"(classOf[${t.finalResultType.erasure}], ${isCaseClass(t) || isCaseObject(t) || isSealed(t)})"
300-
)}"""
293+
val setClassToCaseClassMap = flattenedFieldTypes.map(t =>
294+
q"""classToCaseClassMap ++= ${flattenTypeArgs(t).map(t =>
295+
q"(classOf[${t.finalResultType.erasure}], ${isCaseClass(t) || isCaseObject(t) || isSealed(t)})"
296+
)}"""
301297
)
302298

303299
q"""
@@ -329,7 +325,7 @@ private[codecs] object CaseClassCodec {
329325
writer.writeName($key)
330326
this.writeFieldValue($key, writer, this.bsonNull, encoderContext)
331327
}"""
332-
case _ => q"""
328+
case _ => q"""
333329
val localVal = instanceValue.$name
334330
writer.writeName($key)
335331
this.writeFieldValue($key, writer, localVal, encoderContext)

bson-scala/src/main/scala/org/mongodb/scala/bson/collection/BaseDocument.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ private[bson] trait BaseDocument[T] extends Traversable[(String, BsonValue)] wit
8686
case None => default.value
8787
}
8888

89-
//scalastyle:off spaces.after.plus method.name
89+
// scalastyle:off spaces.after.plus method.name
9090
/**
9191
* Creates a new document containing a new key/value and all the existing key/values.
9292
*
@@ -101,7 +101,7 @@ private[bson] trait BaseDocument[T] extends Traversable[(String, BsonValue)] wit
101101
elems.foreach(elem => bsonDocument.put(elem.key, elem.value))
102102
apply(bsonDocument)
103103
}
104-
//scalastyle:on spaces.after.plus
104+
// scalastyle:on spaces.after.plus
105105

106106
/**
107107
* Removes one or more elements to this document and returns a new document.

bson-scala/src/test/scala/org/mongodb/scala/bson/codecs/IterableCodecSpec.scala

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,11 @@ class IterableCodecSpec extends BaseSpec {
5757

5858
writer.writeStartDocument()
5959
writer.writeName("array")
60-
codec.encode(writer, List(Map("a" -> 1, "b" -> 2, "c" -> null)), EncoderContext.builder().build()) // scalastyle:ignore
60+
codec.encode(
61+
writer,
62+
List(Map("a" -> 1, "b" -> 2, "c" -> null)),
63+
EncoderContext.builder().build()
64+
) // scalastyle:ignore
6165
writer.writeEndDocument()
6266
writer.getDocument should equal(BsonDocument("{array : [{a: 1, b: 2, c: null}]}"))
6367
}
@@ -98,9 +102,13 @@ class IterableCodecSpec extends BaseSpec {
98102
}
99103

100104
it should "use the provided transformer" in {
101-
val codec = IterableCodec(DEFAULT_CODEC_REGISTRY, BsonTypeClassMap(), new Transformer {
102-
override def transform(objectToTransform: Any): AnyRef = s"$objectToTransform"
103-
})
105+
val codec = IterableCodec(
106+
DEFAULT_CODEC_REGISTRY,
107+
BsonTypeClassMap(),
108+
new Transformer {
109+
override def transform(objectToTransform: Any): AnyRef = s"$objectToTransform"
110+
}
111+
)
104112
val reader = new BsonDocumentReader(BsonDocument("{array : [1, 2, 3]}"))
105113

106114
reader.readStartDocument()

driver-scala/src/it/scala/org/mongodb/scala/CrudTest.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
package org.mongodb.scala
1818

1919
import com.mongodb.client.Fixture.getMongoClientSettingsBuilder
20-
import com.mongodb.client.{ AbstractCrudTest }
20+
import com.mongodb.client.AbstractCrudTest
2121
import com.mongodb.event.CommandListener
2222
import org.bson.{ BsonArray, BsonDocument }
2323
import org.mongodb.scala.syncadapter.SyncMongoClient

driver-scala/src/it/scala/org/mongodb/scala/RequiresMongoDBISpec.scala

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@ trait RequiresMongoDBISpec extends BaseSpec with BeforeAndAfterAll {
7575

7676
def withDatabase(dbName: String)(testCode: MongoDatabase => Any): Unit = {
7777
withClient { client =>
78-
val databaseName = if (dbName.startsWith(DB_PREFIX)) dbName.take(63) else s"$DB_PREFIX$dbName".take(63) // scalastyle:ignore
78+
val databaseName =
79+
if (dbName.startsWith(DB_PREFIX)) dbName.take(63) else s"$DB_PREFIX$dbName".take(63) // scalastyle:ignore
7980
val mongoDatabase = client.getDatabase(databaseName)
8081
try testCode(mongoDatabase) // "loan" the fixture to the test
8182
finally {
@@ -98,18 +99,19 @@ trait RequiresMongoDBISpec extends BaseSpec with BeforeAndAfterAll {
9899
}
99100
}
100101

101-
lazy val isSharded: Boolean = if (!TestMongoClientHelper.isMongoDBOnline) {
102-
false
103-
} else {
104-
Await
105-
.result(
106-
mongoClient().getDatabase("admin").runCommand(Document("isMaster" -> 1)).toFuture(),
107-
WAIT_DURATION
108-
)
109-
.getOrElse("msg", BsonString(""))
110-
.asString()
111-
.getValue == "isdbgrid"
112-
}
102+
lazy val isSharded: Boolean =
103+
if (!TestMongoClientHelper.isMongoDBOnline) {
104+
false
105+
} else {
106+
Await
107+
.result(
108+
mongoClient().getDatabase("admin").runCommand(Document("isMaster" -> 1)).toFuture(),
109+
WAIT_DURATION
110+
)
111+
.getOrElse("msg", BsonString(""))
112+
.asString()
113+
.getValue == "isdbgrid"
114+
}
113115

114116
lazy val buildInfo: Document = {
115117
if (TestMongoClientHelper.isMongoDBOnline) {

0 commit comments

Comments
 (0)