Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove scalastyle in favor of scalafmt (#1267)
- Loading branch information
1 parent
abd0aa4
commit f1e7ed1
Showing
107 changed files
with
2,185 additions
and
2,159 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
OrganizeImports { | ||
groupedImports = Keep | ||
removeUnused = true | ||
} | ||
rules = [ | ||
OrganizeImports | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
version = 2.7.2 | ||
maxColumn = 160 | ||
align.preset = some | ||
rewrite.rules = [ | ||
RedundantBraces, | ||
RedundantParens, | ||
SortModifiers, | ||
PreferCurlyFors | ||
] | ||
assumeStandardLibraryStripMargin = true | ||
optIn.breakChainOnFirstMethodDot = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,21 @@ | ||
package io.finch.argonaut | ||
|
||
import argonaut._ | ||
import argonaut.DecodeJson | ||
import argonaut._ | ||
import cats.syntax.either._ | ||
import io.finch._ | ||
import io.finch.internal.HttpContent | ||
|
||
trait Decoders { | ||
|
||
/** | ||
* Maps Argonaut's [[DecodeJson]] to Finch's [[Decode]]. | ||
*/ | ||
* Maps Argonaut's [[DecodeJson]] to Finch's [[Decode]]. | ||
*/ | ||
implicit def decodeArgonaut[A](implicit d: DecodeJson[A]): Decode.Json[A] = | ||
Decode.json { (b, cs) => | ||
Parse.parse(b.asString(cs)).flatMap(_.as[A].result.leftMap(_._1)) match { | ||
case Right(result) => Right(result) | ||
case Left(error) => Left(new Exception(error)) | ||
case Left(error) => Left(new Exception(error)) | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
package io.finch.circe | ||
|
||
import cats.syntax.show._ | ||
import scala.util.control.NoStackTrace | ||
|
||
import cats.syntax.show._ | ||
|
||
private class CirceError(cause: io.circe.Error) extends Exception with NoStackTrace { | ||
override def getMessage: String = cause.show | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,59 +1,56 @@ | ||
package io.finch.circe | ||
|
||
import java.nio.charset.StandardCharsets | ||
|
||
import cats.MonadError | ||
import cats.effect.Sync | ||
import fs2.{Chunk, Stream} | ||
import io.circe.Decoder | ||
import io.circe.fs2 | ||
import io.circe.iteratee | ||
import io.circe.jawn._ | ||
import io.finch.{Application, Decode, DecodeStream} | ||
import io.finch.internal.HttpContent | ||
import io.finch.{Application, Decode, DecodeStream} | ||
import io.iteratee.Enumerator | ||
import java.nio.charset.StandardCharsets | ||
|
||
trait Decoders { | ||
|
||
/** | ||
* Maps a Circe's [[Decoder]] to Finch's [[Decode]]. | ||
*/ | ||
* Maps a Circe's [[Decoder]] to Finch's [[Decode]]. | ||
*/ | ||
implicit def decodeCirce[A: Decoder]: Decode.Json[A] = Decode.json { (b, cs) => | ||
val decoded = cs match { | ||
case StandardCharsets.UTF_8 => decodeByteBuffer[A](b.asByteBuffer) | ||
case _ => decode[A](b.asString(cs)) | ||
case _ => decode[A](b.asString(cs)) | ||
} | ||
|
||
decoded match { | ||
case Left(error) => Left(new CirceError(error)) | ||
case right => right | ||
case right => right | ||
} | ||
} | ||
|
||
implicit def enumerateCirce[F[_], A: Decoder](implicit | ||
F: MonadError[F, Throwable] | ||
F: MonadError[F, Throwable] | ||
): DecodeStream.Json[Enumerator, F, A] = | ||
DecodeStream.instance[Enumerator, F, A, Application.Json]((enum, cs) => { | ||
DecodeStream.instance[Enumerator, F, A, Application.Json] { (enum, cs) => | ||
val parsed = cs match { | ||
case StandardCharsets.UTF_8 => | ||
enum.map(_.asByteArray).through(iteratee.byteStreamParser[F]) | ||
case _ => | ||
enum.map(_.asString(cs)).through(iteratee.stringStreamParser[F]) | ||
} | ||
parsed.through(iteratee.decoder[F, A]) | ||
}) | ||
} | ||
|
||
implicit def fs2Circe[F[_]: Sync, A: Decoder]: DecodeStream.Json[Stream, F, A] = | ||
DecodeStream.instance[Stream, F, A, Application.Json]((stream, cs) => { | ||
DecodeStream.instance[Stream, F, A, Application.Json] { (stream, cs) => | ||
val parsed = cs match { | ||
case StandardCharsets.UTF_8 => | ||
stream | ||
.mapChunks(chunk => chunk.flatMap(buf => Chunk.array(buf.asByteArray))) | ||
.through(fs2.byteStreamParser[F]) | ||
stream.mapChunks(chunk => chunk.flatMap(buf => Chunk.array(buf.asByteArray))).through(fs2.byteStreamParser[F]) | ||
case _ => | ||
stream | ||
.map(_.asString(cs)) | ||
.through(fs2.stringStreamParser[F]) | ||
stream.map(_.asString(cs)).through(fs2.stringStreamParser[F]) | ||
} | ||
parsed.through(fs2.decoder[F, A]) | ||
}) | ||
} | ||
} |
Oops, something went wrong.