Skip to content

Commit a0953a1

Browse files
author
Arnaud Gourlay
committed
minor: warnings & code cleanup
1 parent 9c28c99 commit a0953a1

File tree

20 files changed

+29
-45
lines changed

20 files changed

+29
-45
lines changed

docs/scala.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,8 @@ The `query` method takes an `Expr` object. `Expr` objects can be composed with o
126126
```scala
127127
Value readHippoResults = client.query(
128128
Select(Value("data"),Get(hippoRef))
129-
).get();
130-
System.out.println("Hippo Spells:\n " + readHippoResults + "\n");
129+
).get()
130+
println("Hippo Spells:\n " + readHippoResults + "\n")
131131
```
132132

133133
The `query` method also accepts a `timeout` parameter. The `timeout` value defines the maximum time a `query` will be allowed to run on the server. If the value is exceeded, the query is aborted. If no `timeout` is defined in scope, a default value is assigned on the server side.

faunadb-common/src/main/java/com/faunadb/common/Connection.java

-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import java.util.concurrent.atomic.AtomicBoolean;
2323
import java.util.concurrent.atomic.AtomicLong;
2424

25-
import static io.netty.util.CharsetUtil.US_ASCII;
2625
import static io.netty.util.CharsetUtil.UTF_8;
2726
import static java.lang.String.format;
2827

faunadb-java/src/main/java/com/faunadb/client/errors/FaunaException.java

-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import java.util.Collections;
77
import java.util.List;
88
import java.util.Optional;
9-
import java.util.stream.Collectors;
109

1110
/**
1211
* The base type for all FaunaDB exceptions.

faunadb-java/src/main/java/com/faunadb/client/query/Language.java

+8-8
Original file line numberDiff line numberDiff line change
@@ -7048,7 +7048,7 @@ public static Expr ToMicros(Expr value) {
70487048
/**
70497049
* Returns a time expression's day of the month, from 1 to 31.
70507050
*
7051-
* @param value an expression. Type: Any
7051+
* @param expr an expression. Type: Any
70527052
* @return a new {@link Expr}
70537053
*/
70547054
public static Expr DayOfMonth(Expr expr) {
@@ -7059,7 +7059,7 @@ public static Expr DayOfMonth(Expr expr) {
70597059
* Returns a time expression's day of the week following ISO-8601 convention,
70607060
* from 1 (Monday) to 7 (Sunday).
70617061
*
7062-
* @param value an expression. Type: Any
7062+
* @param expr an expression. Type: Any
70637063
* @return a new {@link Expr}
70647064
*/
70657065
public static Expr DayOfWeek(Expr expr) {
@@ -7070,7 +7070,7 @@ public static Expr DayOfWeek(Expr expr) {
70707070
* Returns a time expression's day of the year, from 1 to 365, or 366 in a leap
70717071
* year.
70727072
*
7073-
* @param value an expression. Type: Any
7073+
* @param expr an expression. Type: Any
70747074
* @return a new {@link Expr}
70757075
*/
70767076
public static Expr DayOfYear(Expr expr) {
@@ -7080,7 +7080,7 @@ public static Expr DayOfYear(Expr expr) {
70807080
/**
70817081
* Returns the time expression's year, following the ISO-8601 standard.
70827082
*
7083-
* @param value an expression. Type: Any
7083+
* @param expr an expression. Type: Any
70847084
* @return a new {@link Expr}
70857085
*/
70867086
public static Expr Year(Expr expr) {
@@ -7090,7 +7090,7 @@ public static Expr Year(Expr expr) {
70907090
/**
70917091
* Returns a time expression's month of the year, from 1 to 12.
70927092
*
7093-
* @param value an expression. Type: Any
7093+
* @param expr an expression. Type: Any
70947094
* @return a new {@link Expr}
70957095
*/
70967096
public static Expr Month(Expr expr) {
@@ -7100,7 +7100,7 @@ public static Expr Month(Expr expr) {
71007100
/**
71017101
* Returns a time expression's hour of the day, from 0 to 23.
71027102
*
7103-
* @param value an expression. Type: Any
7103+
* @param expr an expression. Type: Any
71047104
* @return a new {@link Expr}
71057105
*/
71067106
public static Expr Hour(Expr expr) {
@@ -7110,7 +7110,7 @@ public static Expr Hour(Expr expr) {
71107110
/**
71117111
* Returns a time expression's minute of the hour, from 0 to 59.
71127112
*
7113-
* @param value an expression. Type: Any
7113+
* @param expr an expression. Type: Any
71147114
* @return a new {@link Expr}
71157115
*/
71167116
public static Expr Minute(Expr expr) {
@@ -7120,7 +7120,7 @@ public static Expr Minute(Expr expr) {
71207120
/**
71217121
* Returns a time expression's second of the minute, from 0 to 59.
71227122
*
7123-
* @param value an expression. Type: Any
7123+
* @param expr an expression. Type: Any
71247124
* @return a new {@link Expr}
71257125
*/
71267126
public static Expr Second(Expr expr) {

faunadb-java/src/main/java/com/faunadb/client/types/Codec.java

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import com.faunadb.client.types.Value.*;
44

5-
import java.util.Collections;
65
import java.util.List;
76
import java.util.Map;
87
import java.util.function.Function;

faunadb-java/src/main/java/com/faunadb/client/types/Deserializer.java

-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
import java.io.IOException;
1212
import java.util.ArrayList;
13-
import java.util.Collections;
1413
import java.util.LinkedHashMap;
1514
import java.util.Iterator;
1615
import java.util.List;

faunadb-java/src/main/java/com/faunadb/client/types/Path.java

-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
import java.util.ArrayList;
44
import java.util.Collections;
55
import java.util.List;
6-
import java.util.Map;
7-
import java.util.function.Function;
86
import java.util.stream.Collectors;
97

108
import static com.faunadb.client.types.Codec.ARRAY;

faunadb-java/src/test/java/com/faunadb/client/ClientSpec.java

-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
import static com.faunadb.client.types.Codec.*;
3131
import static com.faunadb.client.types.Value.NullV.NULL;
3232
import static java.lang.String.format;
33-
import static java.util.Arrays.asList;
3433
import static org.hamcrest.CoreMatchers.*;
3534
import static org.hamcrest.Matchers.aMapWithSize;
3635
import static org.hamcrest.Matchers.containsInAnyOrder;

faunadb-java/src/test/java/com/faunadb/client/DeserializationSpec.java

-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
import org.junit.Test;
1111

1212
import java.io.IOException;
13-
import java.time.Duration;
1413
import java.time.Instant;
1514
import java.time.LocalDate;
1615
import java.time.temporal.ChronoUnit;
@@ -19,10 +18,8 @@
1918
import java.util.Optional;
2019

2120
import static com.faunadb.client.types.Codec.*;
22-
import static com.faunadb.client.types.Value.RefV;
2321
import static org.hamcrest.CoreMatchers.equalTo;
2422
import static org.hamcrest.CoreMatchers.is;
25-
import static java.time.ZoneOffset.UTC;
2623
import static org.junit.Assert.assertThat;
2724

2825
public class DeserializationSpec {

faunadb-scala/src/load/scala/faunadb/FaunaClientFixture.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ trait FaunaClientFixture extends SuiteMixin with BeforeAndAfterAll { self: fixtu
1616
val scheme = Option(System.getenv("FAUNA_SCHEME")) getOrElse { "https" }
1717
val port = Option(System.getenv("FAUNA_PORT")) getOrElse { "443" }
1818

19-
collection.Map("root_token" -> rootKey, "root_url" -> s"${scheme}://${domain}:${port}")
19+
collection.Map("root_token" -> rootKey, "root_url" -> s"$scheme://$domain:$port")
2020
}
2121

2222
_rootClient = FaunaClient(endpoint = config("root_url"), secret = config("root_token"))

faunadb-scala/src/main/scala/faunadb/FaunaClient.scala

-2
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ import scala.compat.java8.FutureConverters._
2222
import scala.compat.java8.OptionConverters._
2323
import scala.concurrent.duration.FiniteDuration
2424
import scala.concurrent.{ ExecutionContext, Future }
25-
import scala.util.{Success, Try}
26-
import scala.util.control.NonFatal
2725

2826
/** Companion object to the FaunaClient class. */
2927
object FaunaClient {

faunadb-scala/src/main/scala/faunadb/errors/FaunaException.scala

-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ case class BadRequestException(response: Option[QueryErrorResponse], message: St
3535

3636
/**
3737
* An exception thrown if FaunaDB responds with an HTTP 404 for non-query endpoints.
38-
* @param message
3938
*/
4039
case class NotFoundException(response: Option[QueryErrorResponse], message: String) extends FaunaException(response, message) {
4140
def this(message: String) = this(None, message)

faunadb-scala/src/main/scala/faunadb/jackson/ValueDeserializer.scala

-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ package faunadb.jackson
33
import com.fasterxml.jackson.core.JsonToken._
44
import com.fasterxml.jackson.core.JsonParser
55
import com.fasterxml.jackson.databind._
6-
import com.fasterxml.jackson.databind.module.SimpleModule
7-
import com.fasterxml.jackson.databind.node.ObjectNode
86
import faunadb.values._
97

108
private[faunadb] class ValueDeserializer extends JsonDeserializer[Value] {

faunadb-scala/src/main/scala/faunadb/query/package.scala

+4-4
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ package query {
8181
* Helper for path syntax
8282
*/
8383
case class Path private (segments: Expr*) extends AnyVal {
84-
def /(sub: Path) = Path(segments ++ sub.segments: _*)
84+
def /(sub: Path): Path = Path(segments ++ sub.segments: _*)
8585
}
8686

8787
/**
@@ -103,7 +103,7 @@ package object query {
103103
// implicit conversions
104104

105105
implicit def strToPath(str: String): Path = Path(Expr(StringV(str)))
106-
implicit def intToPath(int: Int): Path = Path(Expr(LongV(int)))
106+
implicit def intToPath(int: Int): Path = Path(Expr(LongV(int.toLong)))
107107
implicit def pathToExpr(path: Path): Expr = Expr(varargs(path.segments))
108108

109109
// Helpers
@@ -216,7 +216,7 @@ package object query {
216216
*
217217
* '''Reference''': [[https://app.fauna.com/documentation/reference/queryapi#basic-forms]]
218218
*/
219-
def Call(ref: Expr, arguments: Expr*) =
219+
def Call(ref: Expr, arguments: Expr*): Expr =
220220
Expr(ObjectV("call" -> ref.value, "arguments" -> varargs(arguments)))
221221

222222
/**
@@ -235,7 +235,7 @@ package object query {
235235
def Query(fn: (Expr, Expr, Expr, Expr, Expr, Expr, Expr, Expr, Expr) => Expr): Expr = macro QueryMacros.query
236236
def Query(fn: (Expr, Expr, Expr, Expr, Expr, Expr, Expr, Expr, Expr, Expr) => Expr): Expr = macro QueryMacros.query
237237

238-
def Query(lambda: Expr) =
238+
def Query(lambda: Expr): Expr =
239239
Expr(ObjectV("query" -> lambda.value))
240240

241241
/**

faunadb-scala/src/main/scala/faunadb/values/Codec.scala

+6-7
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ object Decoder {
191191
implicit def MapDecoder[T](implicit decoder: Decoder[T]): Decoder[Map[String, T]] = new Decoder[Map[String, T]] {
192192
def decode(v: Value, path: FieldPath) =
193193
v match {
194-
case ObjectV(fields) => {
194+
case ObjectV(fields) =>
195195
val successBuilder = Map.newBuilder[String, T]
196196
val failureBuilder = List.newBuilder[FieldError]
197197

@@ -208,7 +208,6 @@ object Decoder {
208208
VFail(failures)
209209
else
210210
VSuccess(successBuilder.result(), path)
211-
}
212211
case _ => Result.Unexpected(v, "Map", path)
213212
}
214213
}
@@ -386,27 +385,27 @@ object Encoder {
386385
}
387386

388387
implicit object CharEncoder extends Encoder[Char] {
389-
def encode(t: Char) = LongV(t)
388+
def encode(t: Char) = LongV(t.toLong)
390389
}
391390

392391
implicit object ByteEncoder extends Encoder[Byte] {
393-
def encode(t: Byte) = LongV(t)
392+
def encode(t: Byte) = LongV(t.toLong)
394393
}
395394

396395
implicit object ShortEncoder extends Encoder[Short] {
397-
def encode(t: Short) = LongV(t)
396+
def encode(t: Short) = LongV(t.toLong)
398397
}
399398

400399
implicit object IntEncoder extends Encoder[Int] {
401-
def encode(t: Int) = LongV(t)
400+
def encode(t: Int) = LongV(t.toLong)
402401
}
403402

404403
implicit object LongEncoder extends Encoder[Long] {
405404
def encode(t: Long) = LongV(t)
406405
}
407406

408407
implicit object FloatEncoder extends Encoder[Float] {
409-
def encode(t: Float) = DoubleV(t)
408+
def encode(t: Float) = DoubleV(t.toDouble)
410409
}
411410

412411
implicit object DoubleEncoder extends Encoder[Double] {

faunadb-scala/src/main/scala/faunadb/values/Field.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ sealed abstract class Field[T] {
7575
new TypedField(ev(this), dec)
7676

7777
def collect[U, Col[_]](inner: Field[U])(implicit ev: Field[T] =:= Field[Value], cbf: CanBuildFrom[_, U, Col[U]]): Field[Col[U]] =
78-
new CollectionField(ev(this), cbf, inner.get _)
78+
new CollectionField(ev(this), cbf, inner.get)
7979
}
8080

8181
private[values] class SubField(parent: Field[Value], subpath: FieldPath) extends Field[Value] {

faunadb-scala/src/main/scala/faunadb/values/FieldPath.scala

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ object FieldPath {
1010
sealed abstract class FieldPath {
1111
def subValue(v: Result[Value]): Result[Value]
1212

13-
def ++(other: FieldPath) =
13+
def ++(other: FieldPath): FieldPath =
1414
this match {
1515
case FieldPathEmpty => other
1616
case p => FieldPathNode(p, other)
@@ -19,7 +19,7 @@ sealed abstract class FieldPath {
1919

2020
case object FieldPathEmpty extends FieldPath {
2121
override def toString = "/"
22-
def subValue(v: Result[Value]) = v
22+
def subValue(v: Result[Value]): Result[Value] = v
2323
}
2424

2525
case class FieldPathField(field: String) extends FieldPath {

faunadb-scala/src/main/scala/faunadb/values/Value.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package faunadb.values
33
import java.nio.ByteBuffer
44
import java.time.{ Instant, LocalDate }
55
import java.time.format.DateTimeFormatter.ISO_OFFSET_DATE_TIME
6-
import java.util.Base64;
6+
import java.util.Base64
77

88
import com.fasterxml.jackson.annotation._
99
import com.fasterxml.jackson.databind.annotation.JsonDeserialize

faunadb-scala/src/test/scala/faunadb/ClientSpec.scala

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class ClientSpec
2626
val scheme = Option(System.getenv("FAUNA_SCHEME")) getOrElse { "https" }
2727
val port = Option(System.getenv("FAUNA_PORT")) getOrElse { "443" }
2828

29-
collection.Map("root_token" -> rootKey, "root_url" -> s"${scheme}://${domain}:${port}")
29+
collection.Map("root_token" -> rootKey, "root_url" -> s"$scheme://$domain:$port")
3030
}
3131

3232
val rootClient = FaunaClient(endpoint = config("root_url"), secret = config("root_token"))
@@ -978,7 +978,7 @@ class ClientSpec
978978
}
979979

980980
it should "create a role" in {
981-
val name = s"a_role_${aRandomString}"
981+
val name = s"a_role_$aRandomString"
982982

983983
rootClient.query(CreateRole(Obj(
984984
"name" -> name,

faunadb-scala/src/test/scala/faunadb/CodecSpec.scala

+2-2
Original file line numberDiff line numberDiff line change
@@ -102,14 +102,14 @@ class CodecSpec extends FlatSpec with Matchers {
102102

103103
it should "decode aliases" in {
104104
case class Wrapped(s: String)
105-
implicit val wrappedCodec = Codec.Alias[Wrapped, String](_.s, Wrapped(_))
105+
implicit val wrappedCodec = Codec.Alias[Wrapped, String](_.s, Wrapped)
106106

107107
val v1 = StringV("hello")
108108
v1.to[Wrapped].get shouldBe Wrapped("hello")
109109
(Wrapped("hello"): Value) shouldBe v1
110110

111111
case class DoubleWrapped(w: Wrapped)
112-
implicit val doubleWrappedCodec = Codec.Alias[DoubleWrapped, Wrapped](_.w, DoubleWrapped(_))
112+
implicit val doubleWrappedCodec = Codec.Alias[DoubleWrapped, Wrapped](_.w, DoubleWrapped)
113113

114114
val v2 = StringV("hello")
115115
v2.to[DoubleWrapped].get shouldBe DoubleWrapped(Wrapped("hello"))

0 commit comments

Comments
 (0)