Skip to content

Update scalafmt-core to 3.7.1 #268

Merged
merged 3 commits into from
Feb 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Scala Steward: Reformat with scalafmt 3.7.1
cf050cfeb9164f45d77febbd4e217487aafaa549
2 changes: 1 addition & 1 deletion .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version ="3.6.1"
version ="3.7.1"

runner.dialect = scala213

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,13 @@ import ru.tinkoff.phobos.encoding.{ElementEncoder, PhobosStreamWriter}

private[phobos] object XmlEntryElementEncoder extends ElementEncoder[XmlEntry] {

override def encodeAsElement(entry: XmlEntry, sw: PhobosStreamWriter, localName: String, namespaceUri: Option[String], preferredNamespacePrefix: Option[String]): Unit = {
override def encodeAsElement(
entry: XmlEntry,
sw: PhobosStreamWriter,
localName: String,
namespaceUri: Option[String],
preferredNamespacePrefix: Option[String],
): Unit = {
entry match {
case leaf: XmlLeaf =>
leaf.companion.elementEncoder.encodeAsElement(leaf.value, sw, localName, namespaceUri, preferredNamespacePrefix)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class XmlEntryElementDecoderTest extends AnyWordSpec with Matchers with DiffShou
)

result.map(util.AstTransformer.sortNodeValues) shouldMatchTo (
util.AstTransformer.sortNodeValues(n).asRight[DecodingError],
util.AstTransformer.sortNodeValues(n).asRight[DecodingError]
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,9 +177,9 @@ private[phobos] abstract class Derivation(val c: blackbox.Context) {
.flatten

val params = caseParams.zip(annotations).map { case (paramType, param) =>
val category = fetchCategory(param)
val category = fetchCategory(param)
val (namespace, preferredNamespacePrefix) = fetchNamespace(param, category)
val localName = param.name.decodedName.toString
val localName = param.name.decodedName.toString
val xmlName: Tree = param.annotations.collectFirst {
case annotation if annotation.tree.tpe =:= renamedType =>
annotation.tree.children.tail.collectFirst { case t @ Literal(Constant(_: String)) =>
Expand Down
13 changes: 6 additions & 7 deletions modules/core/src/main/scala/ru/tinkoff/phobos/Namespace.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,17 @@ package ru.tinkoff.phobos
*
* case object nsi { implicit val ns: Namespace[nsi.type] = Namespace.mkInstance("example.com") }
*
* Value getPreferredPrefix is an optional preferred prefix to associate with this namespace.
* Prefix MUST contain only letters, digits and '_', '-' characters, otherwise encoding may fail with an error.
* If preferred prefix is declared via mkInstance, illegal characters are filtered out.
* Value getPreferredPrefix is an optional preferred prefix to associate with this namespace. Prefix MUST contain only
* letters, digits and '_', '-' characters, otherwise encoding may fail with an error. If preferred prefix is declared
* via mkInstance, illegal characters are filtered out.
*
* If there are several prefixes for one namespace URI, namespaces may be declared twice.
*
* Note: Two namespaces with different prefixes and equal URIs are equal, so users may not declare preferred prefixes
* and rely on automatically generated ones.
* and rely on automatically generated ones.
*
* For example, these two documents are equal, because namespace URIs are equal:
* <xmpl:foo xmlns:xmpl="example.com">value</xmpl:foo>
* <ans1:foo xmlns:ans1="example.com">value</ans1:foo>
* For example, these two documents are equal, because namespace URIs are equal: <xmpl:foo
* xmlns:xmpl="example.com">value</xmpl:foo> <ans1:foo xmlns:ans1="example.com">value</ans1:foo>
*
* See package 'annotations' for more convenient syntax.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -728,7 +728,7 @@ class DecoderDerivationTest extends AnyWordSpec with Matchers {
val barList =
Bar[List, Option](
Some("qux value"),
List(Foo[List](List(123), List("b value 1", "b value 2", "b value 3"), Nil))
List(Foo[List](List(123), List("b value 1", "b value 2", "b value 3"), Nil)),
)

val barOptionString =
Expand Down Expand Up @@ -1540,7 +1540,7 @@ class DecoderDerivationTest extends AnyWordSpec with Matchers {
d: Int,
@xmlns(tcs) e: String,
f: Double,
qux: List[Qux]
qux: List[Qux],
)
implicit val fooDecoder: ElementDecoder[Foo] = deriveElementDecoder

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -395,10 +395,10 @@ class EncoderDerivationTest extends AnyWordSpec with Matchers {
"work for higher kinded data" in {
case class Foo[F[_]](a: F[Int], b: F[String], c: F[Int])
implicit val fooOptionEncoder: XmlEncoder[Foo[Option]] = deriveXmlEncoder("foo")
implicit val fooListEncoder: XmlEncoder[Foo[List]] = deriveXmlEncoder("foo")
implicit val fooListEncoder: XmlEncoder[Foo[List]] = deriveXmlEncoder("foo")

val fooOption = Foo[Option](Some(123), Some("b value"), None)
val fooList = Foo[List](List(123), List("b value 1", "b value 2", "b value 3"), Nil)
val fooList = Foo[List](List(123), List("b value 1", "b value 2", "b value 3"), Nil)

val fooOptionString =
"""<?xml version='1.0' encoding='UTF-8'?>
Expand All @@ -424,18 +424,18 @@ class EncoderDerivationTest extends AnyWordSpec with Matchers {
"work for nested higher-kinded data" in {
case class Foo[F[_]](a: F[Int], b: F[String], c: F[Int])
implicit val fooOptionEncoder: ElementEncoder[Foo[Option]] = deriveElementEncoder
implicit val fooListEncoder: ElementEncoder[Foo[List]] = deriveElementEncoder
implicit val fooListEncoder: ElementEncoder[Foo[List]] = deriveElementEncoder

case class Bar[F[_], G[_]](@attr qux: G[String], foo: F[Foo[F]])
implicit val barOptionEncoder: XmlEncoder[Bar[Option, Option]] = deriveXmlEncoder("bar")
implicit val barListEncoder: XmlEncoder[Bar[List, Option]] = deriveXmlEncoder("bar")
implicit val barListEncoder: XmlEncoder[Bar[List, Option]] = deriveXmlEncoder("bar")

val barOption =
Bar[Option, Option](Some("qux value"), Some(Foo[Option](Some(123), Some("b value"), None)))
val barList =
Bar[List, Option](
Some("qux value"),
List(Foo[List](List(123), List("b value 1", "b value 2", "b value 3"), Nil))
List(Foo[List](List(123), List("b value 1", "b value 2", "b value 3"), Nil)),
)

val barOptionString =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ class ElementEncoderTest extends AnyWordSpec with Matchers with EncoderTestBase
val buff = new ByteArrayOutputStream(512)
val sw = buildStreamWriter(new WriterConfig(), buff)

ElementEncoder[OffsetDateTime].encodeAsElement(OffsetDateTime.parse("2019-10-27T18:27:26.1279855+05:00"), sw, "Date", None, None)
ElementEncoder[OffsetDateTime]
.encodeAsElement(OffsetDateTime.parse("2019-10-27T18:27:26.1279855+05:00"), sw, "Date", None, None)

sw.flush()

Expand Down