Skip to content

Commit 1686551

Browse files
committed
scala fmt and style
1 parent be6355a commit 1686551

29 files changed

+478
-179
lines changed

build.sbt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,14 @@ libraryDependencies += "ch.qos.logback" % "logback-classic" % "1.2.3" % Test
3131

3232
libraryDependencies += "com.typesafe" % "config" % "1.3.3" % Test
3333

34-
libraryDependencies += "joda-time" % "joda-time" % "2.10" % Test
34+
libraryDependencies += "joda-time" % "joda-time" % "2.10.1" % Test
3535

36-
libraryDependencies += "org.json4s" %% "json4s-native" % "3.6.1" % Test
36+
libraryDependencies += "org.json4s" %% "json4s-native" % "3.6.2" % Test
3737

3838
libraryDependencies += "com.github.pathikrit" %% "better-files" % "3.6.0" % Test
3939

4040

41-
libraryDependencies += "org.mongodb.scala" %% "mongo-scala-driver" % "2.4.2"
41+
libraryDependencies += "org.mongodb.scala" %% "mongo-scala-driver" % "2.5.0"
4242

4343
libraryDependencies += "com.typesafe.scala-logging" %% "scala-logging" % "3.9.0"
4444

project/build.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
sbt.version=1.2.4
1+
sbt.version=1.2.6

project/plugin.sbt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ addSbtPlugin("com.orrsella" % "sbt-stats" % "1.0.7")
22

33
addSbtPlugin("org.scalastyle" %% "scalastyle-sbt-plugin" % "1.0.0")
44

5+
addSbtPlugin("com.geirsson" % "sbt-scalafmt" % "1.5.1")
6+
7+
58
addSbtPlugin("org.scalariform" % "sbt-scalariform" % "1.8.0")
69

710
addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.5.1")

scalastyle-config.xml

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
<scalastyle>
2+
<name>Scalastyle standard configuration</name>
3+
<check level="warning" class="org.scalastyle.file.FileTabChecker" enabled="true"></check>
4+
<check level="warning" class="org.scalastyle.file.FileLengthChecker" enabled="true">
5+
<parameters>
6+
<parameter name="maxFileLength"><![CDATA[800]]></parameter>
7+
</parameters>
8+
</check>
9+
<check level="warning" class="org.scalastyle.file.HeaderMatchesChecker" enabled="false">
10+
<parameters>
11+
<parameter name="header"><![CDATA[// Copyright (C) 2011-2012 the original author or authors.
12+
// See the LICENCE.txt file distributed with this work for additional
13+
// information regarding copyright ownership.
14+
//
15+
// Licensed under the Apache License, Version 2.0 (the "License");
16+
// you may not use this file except in compliance with the License.
17+
// You may obtain a copy of the License at
18+
//
19+
// http://www.apache.org/licenses/LICENSE-2.0
20+
//
21+
// Unless required by applicable law or agreed to in writing, software
22+
// distributed under the License is distributed on an "AS IS" BASIS,
23+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
24+
// See the License for the specific language governing permissions and
25+
// limitations under the License.]]></parameter>
26+
</parameters>
27+
</check>
28+
<check level="warning" class="org.scalastyle.scalariform.SpacesAfterPlusChecker" enabled="true"></check>
29+
<check level="warning" class="org.scalastyle.file.WhitespaceEndOfLineChecker" enabled="true"></check>
30+
<check level="warning" class="org.scalastyle.scalariform.SpacesBeforePlusChecker" enabled="true"></check>
31+
<check level="warning" class="org.scalastyle.file.FileLineLengthChecker" enabled="true">
32+
<parameters>
33+
<parameter name="maxLineLength"><![CDATA[160]]></parameter>
34+
<parameter name="tabSize"><![CDATA[4]]></parameter>
35+
</parameters>
36+
</check>
37+
<check level="warning" class="org.scalastyle.scalariform.ClassNamesChecker" enabled="true">
38+
<parameters>
39+
<parameter name="regex"><![CDATA[[A-Z][A-Za-z]*]]></parameter>
40+
</parameters>
41+
</check>
42+
<check level="warning" class="org.scalastyle.scalariform.ObjectNamesChecker" enabled="true">
43+
<parameters>
44+
<parameter name="regex"><![CDATA[[A-Z][A-Za-z]*]]></parameter>
45+
</parameters>
46+
</check>
47+
<check level="warning" class="org.scalastyle.scalariform.PackageObjectNamesChecker" enabled="true">
48+
<parameters>
49+
<parameter name="regex"><![CDATA[^[a-z][A-Za-z]*$]]></parameter>
50+
</parameters>
51+
</check>
52+
<check level="warning" class="org.scalastyle.scalariform.EqualsHashCodeChecker" enabled="true"></check>
53+
<check level="warning" class="org.scalastyle.scalariform.IllegalImportsChecker" enabled="true">
54+
<parameters>
55+
<parameter name="illegalImports"><![CDATA[sun._,java.awt._]]></parameter>
56+
</parameters>
57+
</check>
58+
<check level="warning" class="org.scalastyle.scalariform.ParameterNumberChecker" enabled="true">
59+
<parameters>
60+
<parameter name="maxParameters"><![CDATA[8]]></parameter>
61+
</parameters>
62+
</check>
63+
<check level="warning" class="org.scalastyle.scalariform.MagicNumberChecker" enabled="true">
64+
<parameters>
65+
<parameter name="ignore"><![CDATA[-1,0,1,2,3]]></parameter>
66+
</parameters>
67+
</check>
68+
<check level="warning" class="org.scalastyle.scalariform.NoWhitespaceBeforeLeftBracketChecker" enabled="true"></check>
69+
<check level="warning" class="org.scalastyle.scalariform.NoWhitespaceAfterLeftBracketChecker" enabled="true"></check>
70+
<check level="warning" class="org.scalastyle.scalariform.ReturnChecker" enabled="true"></check>
71+
<check level="warning" class="org.scalastyle.scalariform.NullChecker" enabled="true"></check>
72+
<check level="warning" class="org.scalastyle.scalariform.NoCloneChecker" enabled="true"></check>
73+
<check level="warning" class="org.scalastyle.scalariform.NoFinalizeChecker" enabled="true"></check>
74+
<check level="warning" class="org.scalastyle.scalariform.CovariantEqualsChecker" enabled="true"></check>
75+
<check level="warning" class="org.scalastyle.scalariform.StructuralTypeChecker" enabled="true"></check>
76+
<check level="warning" class="org.scalastyle.file.RegexChecker" enabled="true">
77+
<parameters>
78+
<parameter name="regex"><![CDATA[println]]></parameter>
79+
</parameters>
80+
</check>
81+
<check level="warning" class="org.scalastyle.scalariform.NumberOfTypesChecker" enabled="true">
82+
<parameters>
83+
<parameter name="maxTypes"><![CDATA[30]]></parameter>
84+
</parameters>
85+
</check>
86+
<check level="warning" class="org.scalastyle.scalariform.CyclomaticComplexityChecker" enabled="true">
87+
<parameters>
88+
<parameter name="maximum"><![CDATA[10]]></parameter>
89+
</parameters>
90+
</check>
91+
<check level="warning" class="org.scalastyle.scalariform.UppercaseLChecker" enabled="true"></check>
92+
<check level="warning" class="org.scalastyle.scalariform.SimplifyBooleanExpressionChecker" enabled="true"></check>
93+
<check level="warning" class="org.scalastyle.scalariform.IfBraceChecker" enabled="true">
94+
<parameters>
95+
<parameter name="singleLineAllowed"><![CDATA[true]]></parameter>
96+
<parameter name="doubleLineAllowed"><![CDATA[false]]></parameter>
97+
</parameters>
98+
</check>
99+
<check level="warning" class="org.scalastyle.scalariform.MethodLengthChecker" enabled="true">
100+
<parameters>
101+
<parameter name="maxLength"><![CDATA[50]]></parameter>
102+
</parameters>
103+
</check>
104+
<check level="warning" class="org.scalastyle.scalariform.MethodNamesChecker" enabled="true">
105+
<parameters>
106+
<parameter name="regex"><![CDATA[^[a-z][A-Za-z0-9]*$]]></parameter>
107+
</parameters>
108+
</check>
109+
<check level="warning" class="org.scalastyle.scalariform.NumberOfMethodsInTypeChecker" enabled="true">
110+
<parameters>
111+
<parameter name="maxMethods"><![CDATA[30]]></parameter>
112+
</parameters>
113+
</check>
114+
<check level="warning" class="org.scalastyle.scalariform.PublicMethodsHaveTypeChecker" enabled="true"></check>
115+
<check level="warning" class="org.scalastyle.file.NewLineAtEofChecker" enabled="true"></check>
116+
<check level="warning" class="org.scalastyle.file.NoNewLineAtEofChecker" enabled="false"></check>
117+
</scalastyle>

src/main/scala/com/sfxcode/nosql/mongo/Converter.scala

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@ import com.sfxcode.nosql.mongo.bson.BsonConverter
44
import org.mongodb.scala.Document
55

66
/**
7-
* Created by tom on 20.01.17.
8-
*/
7+
* Created by tom on 20.01.17.
8+
*/
99
object Converter {
1010

11-
def toDocument(value: Any): Document = BsonConverter.toBson(value).asDocument()
11+
def toDocument(value: Any): Document =
12+
BsonConverter.toBson(value).asDocument()
1213

1314
}

src/main/scala/com/sfxcode/nosql/mongo/Field.scala

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ import org.mongodb.scala.model.BsonField
77

88
object Field {
99

10-
def firstField(fieldName: String): BsonField = first(fieldName, "$" + fieldName)
10+
def firstField(fieldName: String): BsonField =
11+
first(fieldName, "$" + fieldName)
1112

1213
def minField(fieldName: String): BsonField = min(fieldName, "$" + fieldName)
1314

@@ -40,11 +41,13 @@ object Field {
4041
}
4142

4243
def groupFields(fieldnames: Iterable[String]): BsonValue = {
43-
val list = fieldnames.map(name => {
44-
if (name.startsWith("$"))
45-
name
46-
else "$" + name
47-
}).toList
44+
val list = fieldnames
45+
.map(name => {
46+
if (name.startsWith("$"))
47+
name
48+
else "$" + name
49+
})
50+
.toList
4851
BsonConverter.toBson(Map("_id" -> list))
4952
}
5053

src/main/scala/com/sfxcode/nosql/mongo/Filter.scala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ object Filter extends LazyLogging {
2828

2929
def notNullFilter(fieldName: String): Bson = not(nullFilter(fieldName))
3030

31-
def dateInRangeFilter(dateFieldKey: String, dateFrom: Date = null, dateUntil: Date = null): Bson = {
31+
def dateInRangeFilter(dateFieldKey: String,
32+
dateFrom: Date = null,
33+
dateUntil: Date = null): Bson = {
3234
if (dateFrom != null && dateUntil != null)
3335
and(gte(dateFieldKey, dateFrom), lte(dateFieldKey, dateUntil))
3436
else if (dateUntil != null)

src/main/scala/com/sfxcode/nosql/mongo/GridFSDAO.scala

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,43 @@ package com.sfxcode.nosql.mongo
33
import com.sfxcode.nosql.mongo.gridfs.Metadata
44
import org.bson.types.ObjectId
55
import org.mongodb.scala.bson.conversions.Bson
6-
import org.mongodb.scala.gridfs.{ GridFSBucket, GridFSFile }
6+
import org.mongodb.scala.gridfs.{GridFSBucket, GridFSFile}
77
import org.mongodb.scala.model.CountOptions
8-
import org.mongodb.scala.{ Completed, Document, MongoDatabase, Observable, ReadConcern, ReadPreference, SingleObservable, WriteConcern }
8+
import org.mongodb.scala.{
9+
Completed,
10+
Document,
11+
MongoDatabase,
12+
Observable,
13+
ReadConcern,
14+
ReadPreference,
15+
SingleObservable,
16+
WriteConcern
17+
}
918

10-
abstract class GridFSDAO(database: MongoDatabase, bucketName: String) extends Metadata(database, bucketName) {
19+
abstract class GridFSDAO(database: MongoDatabase, bucketName: String)
20+
extends Metadata(database, bucketName) {
1121

1222
var bucket = GridFSBucket(database, bucketName)
1323

1424
protected def gridfsBucket: GridFSBucket = bucket
1525

16-
def count(filter: Bson = Document(), options: CountOptions = CountOptions()): Observable[Long] = Files.count(filter, options)
26+
def count(filter: Bson = Document(),
27+
options: CountOptions = CountOptions()): Observable[Long] =
28+
Files.count(filter, options)
1729

18-
def createMetadataIndex(key: String, sortAscending: Boolean = true): SingleObservable[String] = Files.createIndexForField(createMetadataKey(key), sortAscending)
30+
def createMetadataIndex(
31+
key: String,
32+
sortAscending: Boolean = true): SingleObservable[String] =
33+
Files.createIndexForField(createMetadataKey(key), sortAscending)
1934

20-
def dropIndexForName(name: String): SingleObservable[Completed] = Files.dropIndexForName(name)
35+
def dropIndexForName(name: String): SingleObservable[Completed] =
36+
Files.dropIndexForName(name)
2137

22-
def renameFile(id: ObjectId, newFilename: String): Observable[Completed] = gridfsBucket.rename(id, newFilename)
38+
def renameFile(id: ObjectId, newFilename: String): Observable[Completed] =
39+
gridfsBucket.rename(id, newFilename)
2340

24-
def renameFile(file: GridFSFile, newFilename: String): Observable[Completed] = gridfsBucket.rename(file.getId, newFilename)
41+
def renameFile(file: GridFSFile, newFilename: String): Observable[Completed] =
42+
gridfsBucket.rename(file.getId, newFilename)
2543

2644
def withReadConcern(readConcern: ReadConcern): Unit = {
2745
bucket = GridFSBucket(database, bucketName).withReadConcern(readConcern)
@@ -32,11 +50,13 @@ abstract class GridFSDAO(database: MongoDatabase, bucketName: String) extends Me
3250
}
3351

3452
def withChunkSizeBytes(chunkSizeBytes: Int): Unit = {
35-
bucket = GridFSBucket(database, bucketName).withChunkSizeBytes(chunkSizeBytes)
53+
bucket =
54+
GridFSBucket(database, bucketName).withChunkSizeBytes(chunkSizeBytes)
3655
}
3756

3857
def withReadPreference(readPreference: ReadPreference): Unit = {
39-
bucket = GridFSBucket(database, bucketName).withReadPreference(readPreference)
58+
bucket =
59+
GridFSBucket(database, bucketName).withReadPreference(readPreference)
4060
}
4161

4262
def withDisableMD5(disableMD5: Boolean): Unit = {

src/main/scala/com/sfxcode/nosql/mongo/MongoDAO.scala

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
package com.sfxcode.nosql.mongo
22

33
import com.sfxcode.nosql.mongo.operation.Crud
4-
import org.mongodb.scala.{ Document, MongoCollection, MongoDatabase }
4+
import org.mongodb.scala.{Document, MongoCollection, MongoDatabase}
55

66
import scala.reflect.ClassTag
77

88
/**
9-
* Created by tom on 20.01.17.
10-
*/
11-
abstract class MongoDAO[A](database: MongoDatabase, collectionName: String)(implicit ct: ClassTag[A]) extends Crud[A] {
9+
* Created by tom on 20.01.17.
10+
*/
11+
abstract class MongoDAO[A](database: MongoDatabase, collectionName: String)(
12+
implicit ct: ClassTag[A])
13+
extends Crud[A] {
1214

1315
val collection: MongoCollection[A] = database.getCollection[A](collectionName)
1416

src/main/scala/com/sfxcode/nosql/mongo/Sort.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package com.sfxcode.nosql.mongo
22

33
import org.bson.conversions.Bson
4-
import org.mongodb.scala.model.Sorts.{ ascending, descending, orderBy }
4+
import org.mongodb.scala.model.Sorts.{ascending, descending, orderBy}
55

66
object Sort {
77

0 commit comments

Comments
 (0)